I'm trying to make this script kill a person when they touch it if the brick is not transparent.
This is what I have so far.
function onTouched(part) local human = script.Parent.Parent:findFirstChild("Humanoid") if script.Parent.Transparency == 0 then human:TakeDamage(100) end end script.Parent.Touched:connect(onTouched)
function onTouched(part) --"part" is the piece of the human that will be touching the Parent of the script if part.Parent:FindFirstChild("Humanoid") ~= nil then human = part.Parent:FindFirstChild("Humanoid") --Setting "Humanoid" to be set to "human" if script.Parent.Transparency == 0 then human.Health = 0 --This will make the players health go to 0. (Default death) 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!