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:

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.

Last updated