Forja

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

  1. 1You need a Coins stat that saves: the saving script makes one.
  2. 2Publish your game, then in Studio open File, Game Settings, Security and turn on Enable Studio Access to API Services.
  3. 3In the Explorer, hover over ServerScriptService, press +, choose Script and paste this in.
DailyReward · a Script in ServerScriptService
-- 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)end

How it works

  • UpdateAsync reads the time of their last reward and writes the new one in a single step, so two servers can't both pay out.
  • Returning nil from 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
REWARD is the coins, and DAY_SECONDS is 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.
Want something more? The script generator can write it: “A daily reward with a streak: more coins for each day in a row, with a screen that shows the streak”

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