Script finding wrong object in Touched function

Hello everyone, today as of making my game I encountered a very strange bug of sort’s. I made sure to try and debug the script, but to no avail. Then I realize that it is supposed to be written like such when trying to detect the player touching a part. Unless of course I overlooked something. :face_with_monocle:

How do I reproduce this, if it is a bug? :bug:
Currently i’m not sure, but from what I can see, it might have to do with the parameter in the function() with a variable assigned with the same name right above it.

Image’s below:

Error

PS: Topic is in Code Review since the rest of script isn’t bugged, and I want you guys to take a look.

.Touched doesn’t return the player that touched a part, it returns the part that touched it. So, in this case, the right foot of your character touched the pressure plate, and that’s what got passed into the function. You should do .Parent and then check for a humanoid to make sure it’s a player/character.

1 Like

Oh why of course, now it makes sense, thank you. :man_facepalming:

3 Likes