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

How To Add 20EXP To A Player's IntValue Every 5 Minutes?

Asked by 6 years ago
Edited 6 years ago

Good day all!

In my game that I am currently making, people will recieve 20EXP every 5 minutes they spend in the game, but I am having a bit of a wobble with this.

I have my leaderboard script, which works a-okay! But I will link it down here anyways (It has a saving system in it as well.):

local DataSore = game:GetService("DataStoreService")
local ds = DataSore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player)
    local folder = Instance.new("Folder", player)
    folder.Name = "leaderstats"
    local EXP = Instance.new("IntValue", folder)
    EXP.Name = "EXP"
    EXP.Value = ds:GetAsync(player.UserId) or 0
    ds:SetAsync(player.UserId, EXP.Value)
    EXP.Changed:connect(function()
        ds:SetAsync(player.UserId, EXP.Value)
    end)
end)

That's the leaderboard script with a save system in it.

And after that, I've been trying to make the script that gives the player 20EXP every 5 min. I will C+P what I have so far down here >> v

while true do
    wait(300)
    --Something Idk
end

That's all I have for that bit. Can someone please help me with this?

Many thanks.

-Harrydamastr.

0
Actually, I know how to add a number onto a value. It's something like: EXP.Value = EXP.Value +20 or something. Harrydamastr 35 — 6y
0
yea like that GameBoyOtaku 63 — 6y
0
Yes, but how would it identify the player and find it's leaderstats folder?! Harrydamastr 35 — 6y

Answer this question