I have tried many ways but I haven't found a way.
COMMUNITY QUESTION
How do I make a Value not reset it's Value when the player dies?
1 answer
Never tested this before, but you could clone a value to a player whenever they first join, and change the value's parent and clone it back to the player whenever the respawn. For example:
--In a Serverscript in ServerScriptService or something
local value = game:GetService("ReplicatedService"):FindFirstChild("Value") --You should change this to wherever you want to store the initial value (Somewhere not in the player)
game:GetService("Players").PlayerAdded:Connect(function(player)
local valueClone = value:Clone() --Give value to player the first time he/she joins
valueClone.Parent = player
player.CharacterAdded:Connect(function(character)
valueClone.Parent = player; --Parent the value back to the player whenever the character respawns
character:WaitForChild("Humanoid").Died:Connect(function()
valueClone.Parent = game.Workspace -- Or anywhere you deem necessary
end)
end)
end)
I'm pretty sure something along these lines would work. Hope that helps.
Also, please share the code that you have already tried next time you ask a question in this website. It makes it much easier on us to help you.
This discussion is preserved as it was. New answers, comments, and votes are closed.
