How to destroy the old value and replace the value with a new value

Hello, I’m making a system that destroys the old value and replace it with a new value every time the player respawns, but I don’t know how.

Here is the Script:

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player and character then
			local Died = Instance.new("BoolValue", player)
			Died.Name = "Died"
			Died.Value = false
		end
	end)
end)

Any help is appreciated, thanks.

1 Like

u can do it simply like this

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player and character then
            local died = player:FindFirstChild("Died")
            if died then
                 died:Destroy()
            end
			local Died = Instance.new("BoolValue", player)
			Died.Name = "Died"
			Died.Value = false
		end
	end)
end)
2 Likes

Thanks, It works now.

hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.