It's where if the part is transparent, it does no damage, but if it's opaque, it kills you instantly. I don't know what I did wrong.
while true do wait(10) script.Parent.Transparency = 1 wait(10) script.Parent.Transparency = 0 function onTouched (part) if part.Transparency == 0 then local h = script.Parent.Parent:findFirstChild ("Humanoid") h.Health = 0 end end end script.Parent.Touched:connect(onTouched)
This should work:
script.Parent.Touched:connect(function(hit) humanoid = hit.Parent:findFirstChild("Humanoid") if(humanoid ~= nil and script.Parent.Transparency == 0) then humanoid.Health = 0 end end)
What I am doing is checking if a Humanoid exists and that the part is not transparent, if so, kill the player who touched the block, if not, do nothing.