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)
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)
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)