How to make Leaderstats

This will teach you how to script the leaderstats

by OGMGuy

Author Avatar
-- Here is the code for you!
game.Players.PlayerAdded:Connect(function(plr)
    local stats = Instance.new("BoolValue",plr)
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue",stats)
    cash.Name = "Cash"
    cash.Value = 0
end)
-- This only works on Roblox Studio
-- To make this work insert the script in the "ServerScriptStorage"
-- You can name script whatever you want but to be sure name it "Stats"

To be honest with you many of the simulator games have leaderstats.

This is just a basic leaderstats script. There will be more you need to do.

To make this work you actually have to insert another script in this:

"ServerScriptStorage" The code is here to write it in the script.

amount = 2
timedelay = 4
currencyname = "Cash"

while true do
   wait(timedelay)
   for i, v in pairs(game.Players:GetPlayers()) do
       if v:FindFirstChild("leaderstats") and v then
           v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
        end
     end
  end

What this does:

The first code creates the leaderstats.

The second code gives double cash in 4 seconds.

You can change the amount whatever you want but this is just a showcase.

So that is it i hope you learned something from this.

If you want more be sure to like this game.

I will do another if this game hits 1k likes.

View in-game to comment, award, and more!