RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a daily reward system using buttons that says claim. give instruction on how to set up."
-- local script for the claim button local button = script.Parent local player = game.Players.LocalPlayer local playerData = player:WaitForChild("PlayerData") local lastClaimed = playerData:WaitForChild("LastClaimed") local rewardAmount = 100 local function claimReward() local currentTime = os.time() local timeSinceLastClaim = currentTime - lastClaimed.Value if timeSinceLastClaim >= 86400 then -- 86400 seconds in a day player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + rewardAmount lastClaimed.Value = currentTime button.Text = "Claimed!" else button.Text = "Already Claimed. Try again tomorrow." end wait(3) button.Text = "Claim Daily Reward" end button.MouseButton1Click:Connect(claimReward) Instructions: 1. Create a new ScreenGui in the StarterGui. 2. Create a TextButton inside the ScreenGui and name it "ClaimButton". 3. Insert the above local script inside the ClaimButton. 4. Create a folder named "PlayerData" inside each player's instance in the Players service. 5. Inside the "PlayerData" folder, create an IntValue named "LastClaimed" and set its value to 0. 6. Make sure the player has a leaderstats folder with a "Coins" IntValue. Now, when the player clicks the "Claim" button, they will receive the daily reward if they haven't claimed it within the last 24 hours.