Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DatastoreService = game:GetService("DataStoreService")
- local TeleportService = game:GetService("TeleportService")
- local dVersion = 1
- local VIP = 64418164
- local WinsSave = DatastoreService:GetDataStore("Wins "..dVersion)
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = WinsSave:GetAsync(player.UserId) -- Returns a number value.
- local Wins
- if previousData ~= nil then
- Wins = previousData
- else
- Wins = 0
- WinsSave:SetAsync(player.UserId, 0)
- end
- local WinsValue = Instance.new("IntValue", player)
- WinsValue.Name = "Wins"
- WinsValue.Value = Wins
- 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.Wins.Value
- WinsSave:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- 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.."!")
- WinsSave: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 RoundsSave = DatastoreService:GetDataStore("Rounds "..dVersion)
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = RoundsSave:GetAsync(player.UserId) -- Returns a number value.
- local Rounds
- if previousData ~= nil then
- Rounds = previousData
- else
- Rounds = 0
- RoundsSave:SetAsync(player.UserId, 0)
- end
- local RoundsValue = Instance.new("IntValue", player)
- RoundsValue.Name = "Rounds"
- RoundsValue.Value = Rounds
- 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.Rounds.Value
- WinsSave:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- 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.."!")
- WinsSave: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 LivesSave = DatastoreService:GetDataStore("Lives "..dVersion)
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = LivesSave:GetAsync(player.UserId) -- Returns a number value.
- local Lives
- if previousData ~= nil then
- Lives = previousData
- else
- Lives = 0
- LivesSave:SetAsync(player.UserId, 0)
- end
- local LivesValue = Instance.new("IntValue", player)
- LivesValue.Name = "Lives"
- LivesValue.Value = Lives
- 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.Lives.Value
- LivesSave:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local value = player.Lives.Value
- if value ~= nil then
- print("Found data to save for "..player.Name.."!")
- LivesSave: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 CoinsSave = DatastoreService:GetDataStore("Coins "..dVersion)
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
- local Coins
- if previousData ~= nil then
- Coins = previousData
- else
- Coins = 0
- CoinsSave:SetAsync(player.UserId, 0)
- end
- local coinsValue = Instance.new("IntValue", 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 = ''
- if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIP) then
- player.Coins.Value = player.Coins.Value * 2
- 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
- CoinsSave: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.."!")
- CoinsSave: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 SaveRoles = game:GetService("DataStoreService"):GetDataStore("Role")
- game.Players.PlayerAdded:Connect(function(player)
- local Role = Instance.new("StringValue", player)
- Role.Name = "Role"
- Role.Value = player.Role.Value
- if player:WaitForChild("Role").Value >= "Default" then
- player:WaitForChild("Role").Value = "Default"
- elseif player:WaitForChild("Role").Value == "Athlete" then
- player:WaitForChild("Role").Value = "Athlete"
- elseif player:WaitForChild("Role").Value == "Super Protector" then
- player:WaitForChild("Role").Value = "Super Protector"
- elseif player:WaitForChild("Role").Value == "Delivery" then
- player:WaitForChild("Role").Value = "Delivery"
- game.ServerStorage.SavedTools:WaitForChild("PizzaBox"):Clone().Parent = player.Backpack
- end
- end)
- game:BindToClose(function()
- for i,player in pairs(game.Players:GetPlayers()) do
- local value = player.Role.Value
- SaveRoles:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local value = player.Role.Value
- if value ~= nil then
- print("Found data to save for "..player.Name.."!")
- SaveRoles: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()
- player.Rounds.Value = player.Rounds.Value + 1
- end)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement