Hello there Devs! I wanted to make a Interest Rate Sytem which will give the playe interest…
local function giveInterest(player)
local InterestRate = 0.02
while true do
wait(10)
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local currency = leaderstats:FindFirstChild("Coins")
if currency then
local currentBalance = currency.Value
local interest = currentBalance * InterestRate
currency.Value = currentBalance + interest
print(player.Name .. " received interest: " .. interest)
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
giveInterest(player)
end)
What I need help in is that if a player leaves I still want the interest rate system to work and give the player coins that he earned while he was no in the game when he joins the next session