✓ Accepted answer
function onTouched(part)
if part.Parent:FindFirstChild("Humanoid") ~= nil then
human = part.Parent:FindFirstChild("Humanoid")
if script.Parent.Transparency == 0 then
human.Health = 0
end
end
end
script.Parent.Touched:connect(onTouched)
This should work, you had a lot of errors present.
First, when you are looking at function onTouched(part) keep in mind that part is the object we are going to be manipulating. That part will be the object touching the script's Parent.
I added a conditional statement that will check to see if the Parent of part has a "Humanoid" object in it. If it does, then it will check to see if the Parent of the script is transparent. If it is not transparent, it will kill the player.
If this does not help, let me know!
1 comment
Please fix this so that it is in the code block format.