Model Collision

Are you able to toggle the collision of an entire model through a script?

Can I use this line of code?

model.CanCollide = false

Please help!

Loop through it’s children and set CanCollide false for each part.

1 Like

Like others have said, loop through the models contents and get the descendants. Check if the object is a part, and if it is, make it cancollide false.

Hope this helps!

Models dont have a CanCollide property, though you can loop through its children’s parts.

The way you would do this is to use the IsA function to check if the instance is part of the superclass BasePart, since all BasePart have a cancollide property.

for i, v in pairs(model:GetChildren() do
if v:IsA("BasePart") then
v.CanCollide = false
end
end)
1 Like

Thanks! I guess I forgot that for loops existed

Quick question:
What’s the difference between a Part and a BasePart?

BasePart is a superclass, think of it as a table full of classes. Instances such as Parts, MeshParts, Wedges, Unions and etc.

Part is the simple bricks you use to make structures. Basically the IsA function will compare if the instance is part of the specific class