Anchored part does not fire Touched event

Anchored part does not fire Touched event

I was trying to make a moving part that had a chance of destroying every part that it hit, but it didn’t work, so I tried to figure out a way to make it work. I tried every combination of changing CanCollide, CanTouch, CanQuery and anchored on all parts, and I found out that it doesn’t work when the part being checked is anchored. I attached a video showing what I mean. Any help would be appreciated :smiling_face:

2 Likes

This is a strange bug. The issue is not that your part is anchored. If it is anchored and not moving, if other parts touch it it will fire the event. The issues is that while being anchored, you are moving it with a tween. Seems that physics calculations think the part is still in the same place, even tho visually it is moving, thats why the event doesn’t fire.

As a workaround to this, you don’t really need to anchor it when moving with tween, because as you can see other physics forces won’t affect it’s position while you are tweening it’s position. If you need it to be anchored before or after the tween, you can just use tween.Completed:Wait() to anchor it after tween ends.

Nonetheless if someone with access to bug reports category sees this, please report this issue.

1 Like

I don’t believe this is a bug as it is a documented part of the Touched event.
From https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched:

This event only fires as a result of physics movement, so it will not fire if the CFrame property was changed such that the part overlaps another part.

1 Like

You could also try using WorldRoot:GetPartsInPart, the less accurate but less intensive WorldRoot:GetPartBoundsInBox, or maybe WorldRoot:ArePartsTouchingOthers (I added this for reference, but it doesn’t seem to fit your use case) I believe they will all correctly give the parts that are touching

2 Likes

Well, you can see when it’s unanchored, it starts moving around slightly and I don’t really want that.

That’s because it’s orientation changes when it touches other parts, or by gravity. In you tween goal just mention it’s orientation too, and it won’t move around even when unanchored

I’m not positive that this will work, but try using an align position instead. Then you can tween the align position’s position instead of the part’s position. Then Roblox physics should work with the part and the touch event will fire.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.