Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I save leaderboard stats?

I am making a hide and seek game and I need to figure out how to save wins. Here is a basic leaderboard script I used.

    local function onPlayerJoin(player)

    	local leaderstats = Instance.new("Folder")
    	leaderstats.Name = "leaderstats"
    	leaderstats.Parent = player
     
    	local gold = Instance.new("IntValue")
    	gold.Name = "Gold"
    	gold.Value = 0
    	gold.Parent = leaderstats
     
    end
     
    game.Players.PlayerAdded:Connect(onPlayerJoin)

It only works for the session in-game, but when I leave it doesn't save.

1 comment

0

use datastores

2 answers

✓ Accepted answer

It doesn't save cause you are using Instance.new. That means it is inserting new value just when join. You should create new leaderboard stats by other method instead. If you want to know how to create it, check Roblox LUA creating leaderboards. Hope I helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.