Choose a page to begin.

Panel Example

This sample page documents a simple daily reward panel. A player sees a claim button, clicks it, and receives immediate feedback through a status label and a small reward preview.

FAQ

A finished page usually starts with the quick questions, then moves into setup details and reference sections so YOU, the reader understands the feature before jumping into the larger panel example.

This uses a small reward panel example so the page feels more complete and easier to read without getting overly complex.

The example assumes a simple interface with a button and a status label. Each section explains one part of that setup before the full script appears later on the page.

Feature Overview

This sample feature is a basic daily reward panel. A player sees a claim button, clicks it, and the interface updates to show a short status message and a preview of the reward value.

The sample keeps the player-facing flow separate from the implementation snippets so the button logic, label copy, and reward preview behavior can be checked before the full script is copied.

Reward Flow Snapshot

This summary gives a compact view of the reward flow before the code sections take over. It shows the expected state changes and the panel copy that the sample interface uses while the reward moves from ready to claimed.

Claim Flow

  1. The client resolves ClaimButton and StatusLabel from the reward panel.
  2. The button begins in an idle state and waits for player input.
  3. Clicking the button updates the label immediately so the player gets feedback.
  4. The panel can then settle into a claimed state or a cooldown state.

Reward State Table

StateButton TextStatus LabelExpected Behavior
IdleClaim RewardReward readyThe panel is waiting for interaction
PendingClaiming...Request sentDuplicate clicks should be ignored
SuccessClaimedWelcome backReward preview can be shown safely
CooldownTomorrowAlready claimedThe panel stays visible but inactive

Required Instances

This example expects a small screen UI with a few named instances. Listing them directly in the page makes setup clearer before the local script starts calling WaitForChild.

ParameterTypeRequiredDescription
ClaimButtonTextButtonYesButton the player clicks to preview or request the daily reward.
StatusLabelTextLabelYesLabel used to show the current reward status and simple feedback text.
DailyRewardPanelFrameOptionalUseful as the parent container when the example page wants a named frame for layout or visibility checks.
ScreenGuiScreenGuiYesTop-level interface container that holds the reward panel and the named instances used by the sample script.
Make sure the instance names match your UI before using the sample script.

Claim Flow Notes

The reward panel can be described from two angles: the visible UI rules and the underlying button behavior. Keeping both views together makes it easier to compare panel copy against the implementation details without splitting the feature into separate sections.

Panel Expectations

  • The reward panel should load in an idle state before any claim request is made.
  • ClaimButton should only show a pending or cooldown label when the state has actually changed.
  • StatusLabel should stay short enough to fit on one line inside the panel.

Recommended Copy

MomentExample Text
IdleReward ready
PendingRequest sent
SuccessWelcome back
CooldownAlready claimed
Keep the panel copy consistent with the claim flow.

Reward API

This sample panel can also be documented like a small client-server feature. The client sends one claim request, the server resolves the reward state, and the panel applies the returned payload.

1local ReplicatedStorage = game:GetService("ReplicatedStorage")2local remotes = ReplicatedStorage:WaitForChild("Remotes")3local claimDailyReward = remotes:WaitForChild("ClaimDailyReward")4 5local function requestDailyReward()6  return claimDailyReward:InvokeServer()7end
ParameterTypeRequiredDescription
ClaimDailyRewardRemoteFunctionYesRemote entry point used by the client when the player presses the reward button.
response.okbooleanYesSignals whether the reward request should resolve to a claimed state or a cooldown/error state.
response.amountnumberSuccessReward amount returned by the server when the claim succeeds.
response.messagestringYesShort user-facing message the client can place into the status label.

Response Contract

FieldTypeExampleDescription
okbooleantrueWhether the reward request succeeded
statestring"claimed"The resolved reward state returned by the server
amountnumber250Reward amount granted to the player
currencystring"Coins"Reward currency name shown in the UI
messagestring"Welcome back"Short label text the client can display

Failure Path

If the reward is already consumed, the server can return ok = false with a cooldown-style message so the client can disable the button without guessing the result.

Keep the client label copy and the server response fields in sync.

Individual API Reference

Some reward helpers are easier to document on their own, especially when another panel only needs one part of the claim flow instead of the full example.

requestDailyReward

Use this helper when the reward panel should send a single claim request through the configured reward remote and wait for the server response.

code-snippet.luau
1local ReplicatedStorage = game:GetService("ReplicatedStorage")2local remotes = ReplicatedStorage:WaitForChild("Remotes")3local claimDailyReward = remotes:WaitForChild("ClaimDailyReward")4 5local function requestDailyReward()6  return claimDailyReward:InvokeServer()7end
ParameterTypeRequiredDescription
Remotes/ClaimDailyRewardRemoteFunctionYesRemote function used by the client when the player presses the claim button.

applyRewardResponse

Use this helper when the panel already has a response object and only needs to update the button state and status label from the resolved reward result.

code-snippet.luau
1local function applyRewardResponse(claimButton, statusLabel, response)2  if not response.ok then3    claimButton.Text = "Tomorrow"4    setStatusLabel(statusLabel, response.message, false)5    return6  end7 8  claimButton.Text = "Claimed"9  setStatusLabel(10    statusLabel,11    string.format("Received %d Coins", response.amount),12    true13  )14end
ParameterTypeRequiredDescription
claimButtonTextButtonYesButton instance that should switch between idle, claimed, or cooldown text.
statusLabelTextLabelYesStatus label updated with the response message or the granted reward amount.
responsetableYesServer payload containing the final reward state, message, and optional amount fields.

Panel Helpers

These helpers are split out so reward formatting, label updates, and click wiring can change independently without making the final script harder to scan.

1local function formatCoins(amount)2  return string.format("%d Coins", amount)3end
ParameterTypeRequiredDescription
formatCoinsfunctionUsedFormats the reward amount into a readable coins label for the UI.
setStatusLabelfunctionUsedUpdates the label text and color after the reward state changes.
connectClaimButtonfunctionUsedWires the button click to the panel reward flow before the final script combines everything.
Each tab shows one helper used later by the panel example.

Panel UI Example

This combined panel example pulls the earlier helpers together into one local script. It finds the UI instances, formats the reward text, and updates the label when the player clicks the claim button.

code-snippet.luau
1local Players = game:GetService("Players")2local player = Players.LocalPlayer3local screenGui = script.Parent4local claimButton = screenGui:WaitForChild("ClaimButton")5local statusLabel = screenGui:WaitForChild("StatusLabel")6 7local function formatCoins(amount)8  return string.format("%d Coins", amount)9end10 11local function setStatusLabel(label, text, isSuccess)12  label.Text = text13  label.TextColor3 = isSuccess14    and Color3.fromRGB(132, 255, 170)15    or Color3.fromRGB(255, 204, 120)16end17 18claimButton.MouseButton1Click:Connect(function()19  setStatusLabel(statusLabel, "Welcome back, " .. player.Name, true)20  print("Reward preview:", formatCoins(250))21end)

When the button is clicked, the label switches to a success state and the output shows a quick reward preview.