# Daily Reward

### Simplified Daily Reward System Guide

The Giftoin package includes a built-in daily reward system that handles all the logic on the server-side, including catching the event, processing the claim, and sending the result back to the client.

#### 1. Set Up the Client-Side Script

1. Create a new `LocalScript` in `StarterPlayerScripts` or attach it to the GUI element that will handle the claim button.
2. Create a new instance of `RemoteEvent` in `ReplicatedStorage` named `ClaimGiftoinEvent`
3. Use the following code:

```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local claimButton = script.Parent
local claimGiftoinEvent = ReplicatedStorage.GiftoinModule.ClaimGiftoinEvent
local debounce = false

local function updateUI(success, message)
    if success then
        print("Reward claimed successfully: " .. message)
        -- Update UI to show success (e.g., show a success message, update reward counter)
    else
        print("Claim failed: " .. message)
        -- Update UI to show failure (e.g., show an error message)
    end
end

claimButton.MouseButton1Click:Connect(function()
    if debounce then return end
    debounce = true
    claimGiftoinEvent:FireServer()
    debounce = false
end)

claimGiftoinEvent.OnClientEvent:Connect(updateUI)
```

#### 2. Create the Claim Button

1. Design a GUI with a claim button for your daily reward.
2. Attach the LocalScript from step 1 to this button.

#### 3. Customize the Reward UI

* Implement the `updateUI` function to update your game's UI based on the claim result.
* You can show success messages, update reward counters, or display error messages as needed.

#### 4. Additional Considerations

* The GiftoinModule handles all the server-side logic for daily claims, including:
  * Catching the ClaimGiftoinEvent
  * Processing the claim (including checks for 24-hour intervals)
  * Sending the result back to the client
* You don't need to implement any server-side scripts for this functionality.
* The system will automatically ensure that players can only claim once every 24 hours.

#### 5. Potential Use Cases

* **Daily Login Reward**: Use this system as is for a daily login reward.
* **Quest Completion**: Trigger the claim when a player completes a daily quest.

By following this simplified guide, you'll have integrated the Giftoin daily reward system into your game. \
The system handles all server-side logic automatically, allowing you to focus on creating an engaging UI and integrating the reward system into your game's overall design.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.giftoin.org/platform-guides/roblox/additional-example-use-cases/daily-reward.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
