Answered by
5 years ago Edited 5 years ago
The reason your script does not work is because in line 5, an event (like your touched event) can only do 2 things: connect a function
1 | local part = script.Parent |
3 | part.Touched:Connect( function (hit) |
4 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
5 | hit.Parent.Humanoid:TakeDamage( 100 ) |
or wait to do code below it.
1 | local part = script.Parent |
4 | print ( "part has been touched" ) |
So you would do the following instead, where you connect a function that destroys the part when it's touched:
1 | local ShyWhenTouched = script.Parent |
3 | ShyWhenTouched.Touched:Connect( function () |
4 | ShyWhenTouched:Destroy() |
In conclusion, there is no "bool" to a touched event; it can only connect a function or wait to do code below the line.
Hope that works for you, and that you have learned something new :)