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

How do I save leaderboard stats?

Asked by 5 years ago

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.

0
use datastores User#23365 30 — 5y

2 answers

Log in to vote
1
Answered by
kapipi12 133
5 years ago

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.

Ad
Log in to vote
-1
Answered by 5 years ago

Use datastore service, it's on wiki .

0
This should be a comment. User#21908 42 — 5y
0
^ LoganboyInCO 150 — 5y

Answer this question