Part Touched Event not working 11/10/2021

Ok I seriously have no idea why this should NOT be working. I have written this type of code thousands of times before, I’ve checked if the the part CanTouch is on, checked maybe if there’s a problem with my CollisionGroups both were not a problem and the worse thing is that the output is showing absolutely nothing about what’s happening. How am I supposed to debug a problem is there’s no errors showing up on the output.

Why is my code not working?


Edit: I can’t believe I wasted 2 hours of my time because of a stupid bug.

I know this is a stupid question, but PrimaryPart is set on the model, correct?


Yes, the primarypart is the Head. I forgot to switch the print statement back to “v.PrimaryPart”.

If you try doing a .Touched event on another part does it work?

Well is the head what is getting touched cause that is what you are binding Touched to.

Doesn’t seem to, made a new model with the primarypart set.

Try referencing it by path notation or :FindFirstChild() instead of .PrimaryPart and see if that works.

Yes that’s the PrimaryPart that the model is set to.

Yeah I know, but is the person touching the Head? The primary part only changes the pivot point in the world for coordinate and rotation, not what the hitbox is. You still have to touch the “head” block itself, so if it is invisible and cannot be touched then that will be the issue.

If that is not the case then I do not know what will be causing this.

1 Like

Maybe try this code?

local ButtonsFolder		= workspace.Buttons				-- Locate the folder that contains all the buttons
local Buttons			= ButtonsFolder:GetChildren()	-- Make a table of the children inside the folder

for i, v in pairs(Buttons) do							
		print('Button Touched')

I changed the one in the script and it still doesn’t work. I made a new part with a server script attached to it and… that works…?





I have no clue why it’s doing that… The Touched event has done some weird stuff from time to time but this…

Hey I tried out your code inside a localscript and surprisingly it works…


1 Like

I didn’t know the PrimaryPart did that, nice to know.

Turns out the problem was this, I had thought that I didn’t need a script once it ran all it needed to do.


1 Like

You don’t but you likely still needed it in some capacity.

To provide some more insight: Destroy only stops execution at the next yield. This occurs when the end of your script is reached, and removes any events associated (the .Touched event). The .Touched event does not yield the thread, so the script just terminates without a care for it.

1 Like