Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TeleportService = game:GetService("TeleportService")
- local SaveCurrency = game:GetService("DataStoreService"):GetDataStore("Rounds")
- local SaveCurrency2 = game:GetService("DataStoreService"):GetDataStore("Wins")
- local SavesCurrency3 = game:GetService("DataStoreService"):GetDataStore("Coins")
- local SavesCurrency4 = game:GetService("DataStoreService"):GetDataStore("Lives")
- local SaveRole = game:GetService("DataStoreService"):GetDataStore("Role")
- local SaveTags = game:GetService("DataStoreService"):GetDataStore("Tag")
- game.Players.PlayerAdded:Connect(function(player)
- local Folder = Instance.new("Folder",player)
- Folder.Name = "leaderstats"
- local Currency = Instance.new("NumberValue",Folder)
- Currency.Name = "Rounds"
- Currency.Value = SaveCurrency:GetAsync(player.UserId) or 0
- local Currency2 = Instance.new("NumberValue",Folder)
- Currency2.Name = "Wins"
- Currency2.Value = SaveCurrency2:GetAsync(player.UserId) or 0
- local Currency3 = Instance.new("NumberValue",player)
- Currency3.Name = "Coins"
- Currency3.Value = SavesCurrency3:GetAsync(player.UserId) or 0
- local Currency4 = Instance.new("NumberValue",player)
- Currency4.Name = "Lives"
- Currency4.Value = SavesCurrency4:GetAsync(player.UserId) or 0
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- SaveCurrency:SetAsync(player.UserId,player.leaderstats.Rounds.Value)
- SaveCurrency2:SetAsync(player.UserId,player.leaderstats.Wins.Value)
- SavesCurrency3:SetAsync(player.UserId,player.Coins.Value)
- SavesCurrency4:SetAsync(player.UserId,player.Lives.Value)
- end)
- game.Players.PlayerAdded:Connect(function(player)
- local PreviousData = SaveTags:GetAsync(player.UserId)
- local Tag
- local previousData2 = SaveRole:GetAsync(player.UserId)
- local Role
- if PreviousData ~= nil then
- Tag = PreviousData
- else
- Tag = player.Tag.Value
- end
- if previousData2 ~= nil then
- Role = previousData2
- else
- Role = player.Role.Value
- end
- local TagValue = Instance.new("StringValue", player)
- TagValue.Name = "Tag"
- TagValue.Value = Tag
- local RoleValue = Instance.new("StringValue", player)
- RoleValue.Name = "Role"
- RoleValue.Value = Role
- end)
- game:BindToClose(function()
- for i,player in pairs(game.Players:GetPlayers()) do
- local value = player.Tag.Value
- SaveTags:SetAsync(player.UserId, value)
- local value2 = player.Role.Value
- SaveRole:SetAsync(player.UserId, value2)
- print("Saved data for "..player.Name)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local value = player.Tag.Value
- local value2 = player.Role.Value
- if value ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveTags:SetAsync(player.UserId, value)
- SaveRole:SetAsync(player.UserId, value2)
- print("Saved data for "..player.Name)
- else
- print("Did not manage to find data to save for "..player.Name.."!")
- end
- end)
- game.Players.PlayerAdded:Connect(function(player)
- player.CharacterAdded:Connect(function(char)
- local Humanoid = char.Humanoid
- Humanoid.Died:Connect(function()
- player.leaderstats.Rounds.Value += 1
- end)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement