Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TeleportService = game:GetService("TeleportService")
- local dVersion = 1
- local SaveWins = game:GetService("DataStoreService"):GetOrderedDataStore("Wins", dVersion)
- local VIPGamepass = 0
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = SaveWins:GetAsync(player.UserId)
- local Wins
- if previousData ~= nil then
- Wins = previousData
- else
- Wins = 0
- SaveWins:SetAsync(player.UserId, 0)
- end
- local WinsValue = Instance.new("NumberValue", player)
- WinsValue.Name = "Wins"
- WinsValue.Value = Wins
- end)
- game:BindToClose(function()
- for i, player in pairs(game.Players:GetPlayers()) do
- local Value = player.Wins.Value
- SaveWins:SetAsync(player.UserId, Value)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local Value = player.Wins.Value
- if Value ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveWins:SetAsync(player.UserId, Value)
- print("Saved data for "..player.Name)
- else
- print("Did not manage to find data to save for "..player.Name.."!")
- end
- end)
- local SaveRounds = game:GetService("DataStoreService"):GetOrderedDataStore("Rounds", dVersion)
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = SaveWins:GetAsync(player.UserId)
- local Rounds
- if previousData ~= nil then
- Rounds = previousData
- else
- Rounds = 0
- SaveRounds:SetAsync(player.UserId, 0)
- end
- local WinsValue = Instance.new("NumberValue", player)
- WinsValue.Name = "Rounds"
- WinsValue.Value = Rounds
- end)
- game:BindToClose(function()
- for i, player in pairs(game.Players:GetPlayers()) do
- local Value = player.Rounds.Value
- SaveRounds:SetAsync(player.UserId, Value)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local Value = player.Rounds.Value
- if Value ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveRounds:SetAsync(player.UserId, Value)
- print("Saved data for "..player.Name)
- else
- print("Did not manage to find data to save for "..player.Name.."!")
- end
- end)
- local SaveCoins = game:GetService("DataStoreService"):GetOrderedDataStore("Coins", dVersion)
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = SaveWins:GetAsync(player.UserId)
- local Coins
- if previousData ~= nil then
- Coins = previousData
- else
- Coins = 0
- SaveCoins:SetAsync(player.UserId, 0)
- end
- local WinsValue = Instance.new("NumberValue", player)
- WinsValue.Name = "Coins"
- WinsValue.Value = Coins
- if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepass) then
- player.Coins.Value = player.Coins.Value *2
- end
- end)
- game:BindToClose(function()
- for i, player in pairs(game.Players:GetPlayers()) do
- local Value = player.Coins.Value
- SaveCoins:SetAsync(player.UserId, Value)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local Value = player.Coins.Value
- if Value ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveCoins:SetAsync(player.UserId, Value)
- print("Saved data for "..player.Name)
- else
- print("Did not manage to find data to save for "..player.Name.."!")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement