Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DS = game:GetService("DataStoreService"):GetDataStore("Sim_1") -- This is your game key. If you change it, this will initiate a global stat reset. This basically means that everyones stats will be reset.
- game.Players.PlayerAdded:Connect(function(plr)
- wait()
- local plrkey = "id_"..plr.userId
- local savevalue = plr.leaderstats:WaitForChild("Points") -- This will be your first value in your leaderstats script, it's cApItAl sEnSiTiVe by the way.
- local savevalue2 = plr.leaderstats:WaitForChild("Rebirths") -- This is your secondary value. If you want to add more, copy and paste the same line and cahnge the number to 3
- -- Extra values will go here. If you have more, it'll be: local savevalue3 = plr.leaderstats:WaitForChild(<Value Name>)
- local GetSaved = DS:GetAsync(plrkey)
- if GetSaved then
- savevalue.Value = GetSaved[1]
- savevalue2.Value = GetSaved[2]
- -- Any extra values that you want to save go here. If you have a 3rd, it'll be: savevalue3.Value = GetSaved[3]
- else
- local NumbersForSaving = {savevalue.Value, savevalue2.Value}
- DS:GetAsync(plrkey, NumbersForSaving)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- DS:SetASync("id_"..plr.userId, {plr.leaderstats.Points.Value, plr.leaderstats.Rebirths.Value})
- end)
- -- Note: The SaveData script isn't going to work for you on Roblox Studio. In order for it to work, you have to go into the actual game.
- -- If the SaveData script doesn't work for you, follow these steps:
- -- 1) Go to https://www.roblox.com/create
- -- 2) Find your game, click the options button on it and go to "Configure Game"
- -- 3) Click the box that says "Enable Roblox to use Studio API Services" to make sure the box is checked
- -- 4) Save your changes
- -- 5) Shutdown all servers in the game
- -- 6) Rejoin the game :D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement