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.
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
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.