Basically, what I've been trying to do, is make it so if a player touches this part or is in this part for 5 seconds, they will be killed. The same way a game will kill you if you "are out of the battlefield etc." I've tried to replicate that with this code:
Part = script.Parent
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
wait(5)
Part.TouchEnded:Connect(function(Away)
if Away then
hit.Parent.Humanoid.Health = 100
else
hit.Parent.Humanoid.Health = 0
end
end)
end
end)
I would love to know what I'm doing wrong, along with any other tips or advice. Thanks.

2 comments
Not sure if this would work but worth a try
It didn't work, however the results were definitely interesting. What would happen is, every time I would go fully into the part, I could stay there as long as I wanted but the second I stepped out I would instantly die. And if I was on the outside and just touched it for a second, I would live but the next time I touched it I would instantly die.