Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Simple scripting questions involving getting a model children and checking the properties?

Asked by 9 years ago

I am making a script so it checks if a certain model parts inside are cancollide or not. Please help me figure out how to write a script checking if the model children are cancollide or not.

2 answers

Log in to vote
0
Answered by 9 years ago

Isn't it something like ...

CHILDREN = InsertIndexOfModelHere:GetChildren() --replace InsertIndexOfModelHere with the path to index your model (like script.Parent)
for _, v in pairs (CHILDREN) do
    if v:IsA("BasePart") then
        if v.CanCollide == false then
            print(v.Name.."Is not CanCollide")
        else
            print(v.Name.."IS CANCOLLIDE WOOHOO")
        end
    end
end

Basically what I did here was take the model and use the GetChildren() method to assign all children to the variable CHILDREN in a table.

Then, using a for loop, for every value, I checked if it was a solid Part, and if that Part was cancollide

Then, I printed whether it was or was not.

Ad
Log in to vote
-1
Answered by 9 years ago

One second.

Answer this question