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.
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.
Use datastore service, it's on wiki .