Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make daily reward system?

Asked by 6 years ago

How do you make a daily reward system. (Everyday it gives you 'x' amount of game currency)

0
This is not a request site. You have to give examples of what you've tried. Dog2puppy 168 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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.

01local DataStore = game:GetService("DataStoreService"):GetDataStore("LastLogin") --Get the DataStore.
02 
03 
04Game.Players.PlayerAdded:connect(function(Player)
05        wait()
06    local LastLogin = DataStore:GetAsync(Player.userId)
07        if LastLogin then
08            local Seconds = os.time()-LastLogin
09        local Minutes = Seconds/60
10        local Hours = Minutes/60
11       print("It has been: "..Hours.." hours Since your last reward") --This just prints how much time has passed since your last reward.
12        if Hours >= 24 then
13            print("You get a daily login award") --This happens if 24 hours has passed since his last login so he gets an award!
14       DataStore:SetAsync(Player.userId,os.time())
15        end
16    else
17       DataStore:SetAsync(Player.userId,os.time())
18    end
19end)
Ad
Log in to vote
-3
Answered by 6 years ago
Edited 6 years ago

I have tried something for my old game but I am not sure if it works. In case you want to add daily cash.

1local Humanoid = script.Parent.Humanoid
2function PwntX_X()
3local tag = Humanoid:findFirstChild("creator")
4if tag ~= nil then
5if tag.Value ~= nil then
6local Leaderstats = tag.Value:findFirstChild("leaderstats")
7if Leaderstats ~= nil then
8Leaderstats.Cash.Value = Leaderstats.Cash.Value + 250
9wait ( ) -- 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.
0
This really wouldn't work at all. Dog2puppy 168 — 6y
0
did you try it to say it? SwingingMelons -18 — 6y
0
Wow this code is horrible. greatneil80 2647 — 5y
0
how will that work if theres no os time service RobloxGameingStudios 145 — 4y
0
lol coolmanHDMI 72 — 4y

Answer this question