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 inside the Claim button local button = script.Parent local player = game:GetService("Players").LocalPlayer local datastore = game:GetService("DataStoreService"):GetDataStore("DailyRewards") local function claimReward() local success, err = pcall(function() local lastClaimed = datastore:GetAsync(player.UserId .. "-LastClaimed") local currentDate = os.date("*t", os.time()) if lastClaimed then if currentDate.yday == lastClaimed.yday and currentDate.year == lastClaimed.year then button.Text = "Already Claimed" return end end player.leaderstats.Currency.Value = player.leaderstats.Currency.Value + 100 datastore:SetAsync(player.UserId .. "-LastClaimed", currentDate) button.Text = "Claimed" end) if not success then warn("Error claiming daily reward:", err) end end button.MouseButton1Click:Connect(claimReward) Instructions: 1. Create a ScreenGui within the StarterGui. 2. Add a TextButton inside the ScreenGui and name it "Claim". 3. Add a LocalScript inside the TextButton. 4. Copy the code above into the LocalScript. 5. Make sure you have a Currency value inside the player's leaderstats folder. 6. Now, when the player clicks the "Claim" button, they will receive a daily reward of 100 Currency. The button will update to show if the reward has already been claimed for the day.