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 AddRoundsDataStore = game:GetService("DataStoreService"):GetDataStore("AddRounds")
- local AddWinsDataStore = game:GetService("DataStoreService"):GetDataStore("AddWins")
- local SaveCurrency3 = game:GetService("DataStoreService"):GetDataStore("Coins")
- local SaveExtraLives = game:GetService("DataStoreService"):GetDataStore("Lives")
- local SaveDonation = game:GetService("DataStoreService"):GetDataStore("Donation")
- local VIPGamepassId = 64418164
- game.Players.PlayerAdded:Connect(function(player)
- if game.ReplicatedStorage.Tags.Leaderstats.Value == true then
- local Folder = Instance.new("Folder",player)
- Folder.Name = "leaderstats"
- local Currency = Instance.new("NumberValue",Folder)
- Currency.Name = game.ReplicatedStorage.Tags.RoundsValue.Value
- Currency.Value = SaveCurrency:GetAsync(player.UserId) or 0
- local AddRounds = Instance.new("NumberValue", player)
- AddRounds.Name = "AddRounds"
- AddRounds.Value = AddRoundsDataStore:GetAsync(player.UserId) or 0
- local Currency2 = Instance.new("NumberValue",Folder)
- Currency2.Name = game.ReplicatedStorage.Tags.WinsValue.Value
- Currency2.Value = SaveCurrency2:GetAsync(player.UserId) or 0
- local AddWins = Instance.new("NumberValue", player)
- AddWins.Name = "AddWins"
- AddWins.Value = AddWinsDataStore:GetAsync(player.UserId) or 0
- local previousData = SaveCurrency3:GetAsync(player.UserId)
- local Coins
- if previousData ~= nil then
- Coins = previousData
- else
- Coins = 0
- SaveCurrency3:SetAsync(player.UserId, 0)
- end
- local CoinsValue = Instance.new("NumberValue", player)
- CoinsValue.Name = "Coins"
- CoinsValue.Value = Coins
- local val1 = Instance.new("StringValue",player)
- val1.Name = 'GotPet'
- val1.Value = ''
- local val2 = Instance.new("StringValue",player)
- val2.Name = 'OpenValue'
- val2.Value = ''
- local previousData2 = SaveExtraLives:GetAsync(player.UserId)
- local Lives
- if previousData2 ~= nil then
- Lives = previousData2
- else
- Lives = 0
- SaveExtraLives:SetAsync(player.UserId, 0)
- end
- local ExtraLivesValue = Instance.new("NumberValue", player)
- ExtraLivesValue.Name = "Lives"
- ExtraLivesValue.Value = Lives
- if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepassId) then
- player.Coins.Value = player.Coins.Value * 2
- end
- player.Lives.Value = 5
- local DonationValue = Instance.new("NumberValue", player)
- DonationValue.Name = "Donation"
- DonationValue.Value = SaveDonation:GetAsync(player.UserId) or 0
- if player.AddRounds.Value == 1 then
- player.AddRounds.Value = player.AddRounds.Value - 1
- player.leaderstats.Rounds.Value = player.leaderstats.Rounds.Value + 1
- end
- if player.AddWins.Value == 1 then
- player.AddWins.Value = player.AddWins.Value - 1
- player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
- end
- local Rank = Instance.new("StringValue", player)
- Rank.Name = "Rank"
- Rank.Value = ""
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- if game.ReplicatedStorage.Tags.Leaderstats.Value == true then
- SaveCurrency:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.RoundsValue.Value].Value)
- SaveCurrency2:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.WinsValue.Value].Value)
- AddRoundsDataStore:SetAsync(player.UserId, player.AddRounds.Value)
- AddWinsDataStore:SetAsync(player.UserId, player.AddWins.Value)
- end
- end)
- game:BindToClose(function()
- print("STOPPED!")
- for i,player in pairs(game.Players:GetPlayers()) do
- local value = player.Coins.Value
- SaveCurrency3:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- 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.."!")
- SaveCurrency3: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)
- game:BindToClose(function()
- print("STOPPED!")
- for i, player in pairs(game.Players:GetPlayers()) do
- local value2 = player.Lives.Value
- SaveExtraLives:SetAsync(player.UserId, value2)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local value2 = player.Lives.Value
- if value2 ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveExtraLives: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:BindToClose(function()
- print("STOPPED!")
- for i,player in pairs(game.Players:GetPlayers()) do
- local value = player.Donation.Value
- SaveDonation:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local value = player.Donation.Value
- if value ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveDonation: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 teleportData = TeleportService:GetLocalPlayerTeleportData()
- if teleportData then
- local Player = game.Players:GetPlayerByUserId(teleportData.PlayerName)
- Player:WaitForChild("leaderstats"):WaitForChild("Wins").Value = Player.leaderstats.Wins.Value + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement