Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TeleportService = game:GetService("TeleportService")
- local UnusedContentDataStore = game:GetService("DataStoreService"):GetDataStore("UnusedContent")
- game.Players.PlayerAdded:Connect(function(player)
- local previousData = UnusedContentDataStore:GetAsync(player.UserId)
- local UnusedContent
- if UnusedContent ~= nil then
- UnusedContent = previousData
- else
- UnusedContent = script.UnusedContent.Value
- UnusedContentDataStore:SetAsync(player.UserId, UnusedContent)
- end
- local UnusedContentValue = Instance.new("StringValue", player)
- UnusedContentValue.Name = "UnusedContent"
- UnusedContentValue.Value = UnusedContent
- player.UnusedContent.Value = "On"
- if player.UnusedContent.Value == "On" then
- player.PlayerGui:WaitForChild("DeathScreen").Early_DeathScreen.Disabled = false
- player.PlayerGui:WaitForChild("DeathScreen").Final_DeathScreen.Disabled = true
- player.PlayerGui:WaitForChild("DeathScreen").DeathFrame.DiedFrame.Lives.Visible = true
- else
- player.PlayerGui:WaitForChild("DeathScreen").Early_DeathScreen.Disabled = true
- player.PlayerGui:WaitForChild("DeathScreen").Final_DeathScreen.Disabled = false
- player.PlayerGui:WaitForChild("DeathScreen").DeathFrame.DiedFrame.Lives.Visible = false
- end
- end)
- game:BindToClose(function()
- print("STOPPED!")
- for i,player in pairs(game.Players:GetPlayers()) do
- local value = player.UnusedContent.Value
- UnusedContentDataStore:SetAsync(player.UserId, value)
- print("Saved data for "..player.Name)
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)
- local value = player.UnusedContent.Value
- if value ~= nil then
- print("Found data to save for "..player.Name.."!")
- UnusedContentDataStore: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