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("Playersave3")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = player
- local SwordSkill = Instance.new("NumberValue")
- SwordSkill.Name = "SwordSkill"
- SwordSkill.Parent = leaderstats
- local Cash = Instance.new("IntValue")
- Cash.Name = "Cash"
- Cash.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 SwordSkillData, CashData, RebirthsData
- local success,errormessage = pcall(function()
- SwordSkillData = DataStore:GetAsync("SwordSkill-"..player.UserId)
- CashData = DataStore:GetAsync("Cash-"..player.UserId)
- RebirthsData = DataStore:GetAsync("Rebirths-"..player.UserId)
- end)
- if success then
- if SwordSkillData then
- SwordSkill.Value = SwordSkillData
- Cash.Value = CashData
- Rebirths.Value = RebirthsData
- end
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local succes, errormessage = pcall(function()
- DataStore:SetAsync("SwordSkill-"..player.UserId,player.leaderstats.SwordSkill.Value)
- DataStore:SetAsync("Cash-"..player.UserId,player.leaderstats.Cash.Value)
- DataStore:SetAsync("Rebirths-"..player.UserId,player.leaderstats.Rebirths.Value)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement