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 5 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 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 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.

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)

Ad
Log in to vote
-3
Answered by 5 years ago
Edited 5 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.

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.
0
This really wouldn't work at all. Dog2puppy 168 — 5y
0
did you try it to say it? SwingingMelons -18 — 5y
0
Wow this code is horrible. greatneil80 2647 — 4y
0
how will that work if theres no os time service RobloxGameingStudios 145 — 4y
0
lol coolmanHDMI 72 — 3y

Answer this question