.Touched not detecting anchored parts?

I’m working on a Dragon Ball game and I’m trying to implement destroyable buildings. The way I’m detecting if a beam is touching a part is the .Touched event. The problem here is that the event isn’t detecting anchored parts! I don’t get why, and it’s a big problem as I can’t just unanchor them, they would just fall down and players could move them. How can I fix this? This is how my beam currently looks like:
https://gyazo.com/0cc2232249ae0ea4e661b3b4fbed0504
What it’s supposed to do, is that when the blue beam (cylinder) hits something without a humanoid, it creates an explosion (which already is made after 2 seconds if the beam hasn’t hit anything).
My code:

Effect3.Touched:Connect(function(hit)
  if hit.Parent:FindFirstChild("Humanoid") == nil and hit.Parent:FindFirstChild("Destroyable") and hit.Parent:IsA("Model") then
     for i,v in pairs(hit.Parent:GetChildren()) do
         if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
            v.Anchored = false
            v.CanCollide = false
            -- other piece of code that creates the explosion, no need to include it
         end
      end
   end
end)

(Effect3 is the blue cylinder).
Is this a bug or did I miss something? Thanks to anyone who can help. :smile:

2 Likes

Using .Touched relies that at least one of the two colliding parts is unanchored. If both the parts that are colliding are both anchored the event won’t trigger.

For anything to do with a beam you should be using Raycasting to find the part the beam hit. Since a beam won’t trigger the .Touched event. Raycasting can then return the part it collided.

3 Likes

True, so instead use :GetTouchingParts() not entirely sure if that works.

That will only work if they are intersecting.

1 Like

Yea I had this issue with my hitbox this is what I did.

I made it non anchored still but I gave it a non noticable velocity of 0.1 and I also gave it a maxforce of 1000. I had this issue on a explosion to.

.Touched is kind of iffy when it comes to detecting if a part was touched, so I’d either use :GetTouchingParts() or just raycating the front side of the beam that you want to detect if something was hit

I used to have this problem too. If :GetTouchingParts() doesn’t work, then make a region3 around the object (so that the Region3 is slightly bigger than the object itself). And loop through it whenever you need.

Tried your solution and it works fine. Thank you! :+1: