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

How do I add a Limit onto my leaderboard, without breaking the code?

Asked by
Yezai 2
4 years ago

The script gives players 5 Skulls(Cash) every minute. But I wanted to add a max limit on how many skulls the players can have at one time. when I tried, I realised that 'while true do' is a loop, and I'm not sure how to add the limit onto it, without breaking the script.

local function checkCash(player)

local skulls = Instance.new("StringValue")
skulls.Name = 'Skull Tokens'
skulls.Parent = player

local storage = Instance.new("Folder")
storage.Name = player.Name.."'s Storage"
storage.Parent = replicatedstorage

local ServerSkulls = Instance.new("IntValue")
ServerSkulls.Name = player.Name.."'s Skull Tokens"
ServerSkulls.Parent = storage   
while true do
    if ServerSkulls.Value >= 0 then 
            wait(60)
            ServerSkulls.Value = ServerSkulls.Value+5
            skulls.Value = ServerSkulls.Value
    else
        if ServerSkulls.Value >= 1000000000000 then
            print(player.Name.." has Max Skulls")
            end
        end
    end
end
0
change line 17 to: ServerSkulls.Value = math.min(ServerSkulls.Value+5,1000000000000) ScuffedAI 435 — 4y
0
That should prevent it from exceeding the max value ScuffedAI 435 — 4y
0
Thank you, I'll try that Yezai 2 — 4y
0
Alright that worked, Thanks again :D Yezai 2 — 4y

Answer this question