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
- The client resolves
ClaimButtonandStatusLabelfrom the reward panel. - The button begins in an idle state and waits for player input.
- Clicking the button updates the label immediately so the player gets feedback.
- The panel can then settle into a claimed state or a cooldown state.
Reward State Table
| State | Button Text | Status Label | Expected Behavior |
|---|---|---|---|
| Idle | Claim Reward | Reward ready | The panel is waiting for interaction |
| Pending | Claiming... | Request sent | Duplicate clicks should be ignored |
| Success | Claimed | Welcome back | Reward preview can be shown safely |
| Cooldown | Tomorrow | Already claimed | The 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.
| Parameter | Type | Required | Description |
|---|---|---|---|
| ClaimButton | TextButton | Yes | Button the player clicks to preview or request the daily reward. |
| StatusLabel | TextLabel | Yes | Label used to show the current reward status and simple feedback text. |
| DailyRewardPanel | Frame | Optional | Useful as the parent container when the example page wants a named frame for layout or visibility checks. |
| ScreenGui | ScreenGui | Yes | Top-level interface container that holds the reward panel and the named instances used by 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.
ClaimButtonshould only show a pending or cooldown label when the state has actually changed.StatusLabelshould stay short enough to fit on one line inside the panel.
Recommended Copy
| Moment | Example Text |
|---|---|
| Idle | Reward ready |
| Pending | Request sent |
| Success | Welcome back |
| Cooldown | Already claimed |
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| Parameter | Type | Required | Description |
|---|---|---|---|
| ClaimDailyReward | RemoteFunction | Yes | Remote entry point used by the client when the player presses the reward button. |
| response.ok | boolean | Yes | Signals whether the reward request should resolve to a claimed state or a cooldown/error state. |
| response.amount | number | Success | Reward amount returned by the server when the claim succeeds. |
| response.message | string | Yes | Short user-facing message the client can place into the status label. |
Response Contract
| Field | Type | Example | Description |
|---|---|---|---|
| ok | boolean | true | Whether the reward request succeeded |
| state | string | "claimed" | The resolved reward state returned by the server |
| amount | number | 250 | Reward amount granted to the player |
| currency | string | "Coins" | Reward currency name shown in the UI |
| message | string | "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.
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.
1local ReplicatedStorage = game:GetService("ReplicatedStorage")2local remotes = ReplicatedStorage:WaitForChild("Remotes")3local claimDailyReward = remotes:WaitForChild("ClaimDailyReward")4 5local function requestDailyReward()6 return claimDailyReward:InvokeServer()7end| Parameter | Type | Required | Description |
|---|---|---|---|
| Remotes/ClaimDailyReward | RemoteFunction | Yes | Remote 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.
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| Parameter | Type | Required | Description |
|---|---|---|---|
| claimButton | TextButton | Yes | Button instance that should switch between idle, claimed, or cooldown text. |
| statusLabel | TextLabel | Yes | Status label updated with the response message or the granted reward amount. |
| response | table | Yes | Server 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| Parameter | Type | Required | Description |
|---|---|---|---|
| formatCoins | function | Used | Formats the reward amount into a readable coins label for the UI. |
| setStatusLabel | function | Used | Updates the label text and color after the reward state changes. |
| connectClaimButton | function | Used | Wires the button click to the panel reward flow before the final script combines everything. |
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.
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.