Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This is a script we use to make a game called "The Prison: Behind Bars".
- -- This is a Leaderstats Data Save script
- local dss = game:GetService("DataStoreService")
- local DataStoreToKeep = dss:GetDataStore("TypeWhatYouWantHere")
- game.Players.PlayerAdded:Connect(function(player)
- local ls = Instance.new("Folder",player)
- ls.Name = "leaderstats"
- local money = Instance.new("IntValue",ls)
- money.Name = "Money"
- money.Value = 0
- local data
- local success, errormessage = pcall(function()
- data = DataStoreToKeep:GetAsync(player.UserId.."-money")
- end)
- if success then
- money.Value = data
- else
- warn(errormessage)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local success, errormessage = pcall(function()
- DataStoreToKeep:SetAsync(player.UserId.."-money",player.leaderstats.Money.Value)
- end)
- if success then
- else
- warn(errormessage)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement