I was wondering if someone was able to help explain something to me? It makes sense, but I’d like to know a little more information about it. For what I know, while trying to run a .Touched event on a BasePart (which is a child of something, in this case it’s a ‘hitbox’), I have a for loop within the event that turns the can collide for each child false. When I print all the children within the for loop, it doesn’t show the BasePart in which the event is running on. Like I said, it makes sense, but at the same time how would I go about changing properties of said BasePart. Also, is it only like this for the .Touched event, or does it work this way for every event?
Not sure if this is what you meant, but :GetChildren()
only gives the children of said object and not the object itself. This is why your for loop doesn’t account for the said BasePart
.
Each event is different, they have their own respective parameters.
I guess it’d be easier to show exactly what I’m working with. Basically, when a player touched the hitbox, it plays the animation for pick up. But I call ‘:Destroy’ to remove the hitbox, as it’s not needed anymore. When I run the for loop, I’m running it on the Model, in this case the ‘Crowbar.’ I’ll post the code below.
for _, weaponPart in weapon:GetChildren() do
if weaponPart:IsA("MeshPart") or weaponPart:IsA("BasePart") then
weaponPart.CanCollide = false
hitbox:Destroy()
print(weaponPart)
else
return
end
end
In earlier iterations, you destroy the hitbox. So when you get to where the hitbox should be in the loop, it’s not there anymore.
1 Like