Roblox daily reward script
A reason to come back tomorrow: a player gets coins the first time they join each day, and the time is saved so rejoining doesn't pay out again.
Where it goes
- 1You need a Coins stat that saves: the saving script makes one.
- 2Publish your game, then in Studio open File, Game Settings, Security and turn on Enable Studio Access to API Services.
- 3In the Explorer, hover over ServerScriptService, press +, choose Script and paste this in.
-- From forja.us/tools/roblox-scripts/daily-reward-- Gives a player coins when they join, once every 24 hours.local DataStoreService = game:GetService("DataStoreService")local Players = game:GetService("Players")local REWARD = 50local DAY_SECONDS = 24 * 60 * 60local store = DataStoreService:GetDataStore("DailyReward")local function onPlayerAdded(player) -- Let the script that loads their coins finish first. task.wait(5) local leaderstats = player:FindFirstChild("leaderstats") local coins = leaderstats and leaderstats:FindFirstChild("Coins") if not coins then return end local now = os.time() local due = false local ok, problem = pcall(function() store:UpdateAsync("player_" .. player.UserId, function(last) if last and now - last < DAY_SECONDS then due = false return nil end due = true return now end) end) if not ok then warn("Could not check the daily reward for " .. player.Name .. ": " .. tostring(problem)) return end if due then coins.Value += REWARD endendPlayers.PlayerAdded:Connect(onPlayerAdded)for _, player in Players:GetPlayers() do task.spawn(onPlayerAdded, player)endHow it works
UpdateAsyncreads the time of their last reward and writes the new one in a single step, so two servers can't both pay out.- Returning
nilfrom it leaves the saved time as it was, which is what happens when it isn't time yet. - The coins are added only after the save worked, so a failed save never gives a reward that isn't recorded.
Make it yours
- Change the reward or the wait
REWARDis the coins, andDAY_SECONDSis how long until the next one.- Tell the player
- Fire a RemoteEvent where the coins are added, and show a message from a LocalScript. The script generator can write that part.
Maps to try it on: simulator and tycoon maps
Start from a finished map, and your scripts have a game to run in.
More free Roblox scripts
Roblox kill brick scriptRoblox leaderboard scriptRoblox save data scriptRoblox sprint scriptRoblox double jump scriptRoblox teleport scriptRoblox obby checkpoint scriptRoblox coin pickup scriptRoblox day and night cycle scriptRoblox game pass scriptRoblox developer product scriptRoblox door scriptRoblox tool giver scriptRoblox round system scriptRoblox background music scriptRoblox speed pad scriptRoblox jump pad scriptRoblox VIP door scriptRoblox NPC dialogue scriptRoblox pet follow scriptRoblox gun scriptRoblox admin commands scriptRoblox tycoon dropper scriptRoblox shop GUI script

