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

How would I make a model anchored?

Asked by
zomspi 541 Moderation Voter
4 years ago
Edited 4 years ago

How might I make a model anchored in a script, I tried this but failed:

game.Workspace.Dark:GetChildren().Anchored = false

Dark being the model.

EDIT: Not all of the children are parts so I may have to decipher between parts and non parts.

0
Look up what GetChildren returns hiimgoodpack 2009 — 4y

2 answers

Log in to vote
1
Answered by
Yuuwa0519 197
4 years ago

You can use a for loop! In your case, you would want to loop through the children of the model, check if it is a part (since most instances except for part have anchored property, setting the anchored for a non-part object will result in error and stop the code.), and then anchor it if it is a part. Example code:

local model = script.Parent
local childs = model:GetDescendant() --get's every descendant of the part, for example if there is a child of a child, this function will get that too.

for I,v in pairs(childs) do --for loop
    if v:IsA("BasePart") then --checks if the instance is part.The type "BasePart" applies to every instance that is a part.
        v.Anchored = true
    end
end
0
Thanks! zomspi 541 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

this may work:

children = Item:GetChildren()
    for i = 1, #children do

    local child = children[i]
if child.CassName == "Part" then
child.Anchored = true
end
end

does it work? tell me.

Answer this question