Character is playable even without life

So i have a script that saves if characters is Dead or not but whenever i join the game again when i’m dead my character is playable even if he doesn’t have life has u can see in image (sorry for bad english)

any help will be appreciated

This is the code:

Players.PlayerAdded:Connect(function(player)
	player:SetAttribute("primeiraVez", false)
	player.CharacterAdded:Connect(function(char)
		local getTAH = newData:Get(player, "ValoresIniciais")
		local pegate = player:GetAttribute("primeiraVez")
		if pegate == true then
			getTAH["TaMorto"] = false
		end
		if pegate == false then
			player:SetAttribute("primeiraVez", true)
			if getTAH["TaMorto"] then
				if char:FindFirstChild("Humanoid") then
					local humanoid = char:FindFirstChild("Humanoid")
					humanoid:TakeDamage(math.huge) --kills player
				end
			end
		end
		char:FindFirstChild("Humanoid").Died:Connect(function()
			getTAH["TaMorto"] = true
		end)
	end)
end)
2 Likes

You’ll need to use a DataStore to guarantee that the game will remember that the character has died when they re-join the game

1 Like

i’m already using this(actually using ProfileService), the player come back dead without life, but he’s somehow playable!

See if doing this guarantees that the character dies:

Players.PlayerAdded:Connect(function(player)
	player:SetAttribute("primeiraVez", false)
	player.CharacterAdded:Connect(function(char)
		local getTAH = newData:Get(player, "ValoresIniciais")
		local pegate = player:GetAttribute("primeiraVez")
		if pegate == true then
			getTAH["TaMorto"] = false
		end
		if pegate == false then
			player:SetAttribute("primeiraVez", true)
			if getTAH["TaMorto"] then
				if char:FindFirstChild("Humanoid") then
					local humanoid = char:FindFirstChild("Humanoid")
					humanoid:TakeDamage(math.huge) --kills player
					char.Head.Neck:Destroy() -- Destroys the character's neck to be extra sure they're dead
				end
			end
		end
		char:FindFirstChild("Humanoid").Died:Connect(function()
			getTAH["TaMorto"] = true
		end)
	end)
end)