Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local serverStorage = game:GetService("ServerStorage")
- local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerSave")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = player
- local Coins = Instance.new("NumberValue")
- Coins.Name = "Coins"
- Coins.Parent = leaderstats
- local rebirths = Instance.new("IntValue")
- rebirths.Name = "Rebirths"
- rebirths.Parent = leaderstats
- local dataFolder = Instance.new("Folder")
- dataFolder.Name = player.Name
- dataFolder.Parent = serverStorage.RemoteData
- local debounce = Instance.new("BoolValue")
- debounce.Name = "Debounce"
- debounce.Parent = dataFolder
- local strengthData, rebirthsData
- local success,errormessage = pcall(function()
- strengthData = DataStore:GetAsync("coins-"..player.UserId)
- rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)
- end)
- if success then
- if strengthData then
- coins.Value = coinsData
- rebirths.Value = rebirthsData
- end
- end
- game.Players.PlayerRemoving:Connect(function(player)
- local success, errormessage = pcall(function()
- DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Coins.Value)
- DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Rebirths.Value)
- end)
- end)
- end)
- print("GOT PAST THE WHOLE SCRIPT!") -- make a script in ServerScriptService and paste all of this in
- -- you can delete the print and instructions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement