How do you make a daily reward system. (Everyday it gives you 'x' amount of game currency)
COMMUNITY QUESTION
How do you make daily reward system?
2 answers
You can save the the time since their last login in the datastore. See how much time has passed since his last login. This is just some help. Try to learn.. read.. this is just to help you getting started.
local DataStore = game:GetService("DataStoreService"):GetDataStore("LastLogin") --Get the DataStore.
Game.Players.PlayerAdded:connect(function(Player)
wait()
local LastLogin = DataStore:GetAsync(Player.userId)
if LastLogin then
local Seconds = os.time()-LastLogin
local Minutes = Seconds/60
local Hours = Minutes/60
print("It has been: "..Hours.." hours Since your last reward") --This just prints how much time has passed since your last reward.
if Hours >= 24 then
print("You get a daily login award") --This happens if 24 hours has passed since his last login so he gets an award!
DataStore:SetAsync(Player.userId,os.time())
end
else
DataStore:SetAsync(Player.userId,os.time())
end
end)
I have tried something for my old game but I am not sure if it works. In case you want to add daily cash.
local Humanoid = script.Parent.Humanoid
function PwntX_X()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local Leaderstats = tag.Value:findFirstChild("leaderstats")
if Leaderstats ~= nil then
Leaderstats.Cash.Value = Leaderstats.Cash.Value + 250
wait ( ) -- type in the parenthesis the seconds of a day cause I am bored to estimate now xD and do this a bunch of time, but each times you can change the cash value that is being given. Tell me if it worked.
5 comments
0
This really wouldn't work at all.
0
did you try it to say it?
0
Wow this code is horrible.
0
how will that work if theres no os time service
0
lol
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
This is not a request site. You have to give examples of what you've tried.
Some topics to look into... http://wiki.roblox.com/index.php?title=API:Class/GlobalDataStore http://wiki.roblox.com/index.php?title=Global_namespace/Basic_functions#os.time