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.