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("Wins")
- local SaveCurrency2 = game:GetService("DataStoreService"):GetDataStore("Rounds")
- local SaveCurrency3 = game:GetService("DataStoreService"):GetDataStore("Coins")
- local SaveCurrency4 = game:GetService("DataStoreService"):GetDataStore("Money")
- local VIPGamepassId = 27333933
- local MoneyGamepassId = 22852448
- 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.WinsValue.Value
- Currency.Value = SaveCurrency:GetAsync(player.UserId) or 0
- local Currency2 = Instance.new("NumberValue",Folder)
- Currency2.Name = game.ReplicatedStorage.Tags.RoundsValue.Value
- Currency2.Value = SaveCurrency2: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 = SaveCurrency4:GetAsync(player.UserId)
- local Money
- if previousData ~= nil then
- Money = previousData
- else
- Money = 0
- SaveCurrency3:SetAsync(player.UserId, 0)
- end
- local CoinsValue = Instance.new("NumberValue", player)
- CoinsValue.Name = "Money"
- CoinsValue.Value = Money
- if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIPGamepassId) then
- player.Coins.Value = player.Coins.Value * 2
- end
- if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, MoneyGamepassId) then
- player.Money.Value = player.Money.Value * 2
- end
- 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.WinsValue.Value].Value)
- SaveCurrency2:SetAsync(player.UserId,player.leaderstats[game.ReplicatedStorage.Tags.RoundsValue.Value].Value)
- end
- end)
- game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
- 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() -- Runs whenver the server is about to shut down/stop.
- print("STOPPED!")
- for i,player in pairs(game.Players:GetPlayers()) do
- local value = player.Money.Value
- SaveCurrency4:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local value = player.Money.Value
- if value ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveCurrency4: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.Players.PlayerAdded:connect(function(player)
- player.CharacterAdded:connect(function(char)
- char.Humanoid.Died:connect(function()
- SaveCurrency2:SetAsync(player.UserId, player.leaderstats.Rounds.Value)
- player.leaderstats.Rounds.Value = player.leaderstats.Rounds.Value + 1
- end)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement