How would I go about checking if every part is anchored in a model, and if it's not keep checking until it is?

I need help. Basically, I need to check if every part in a model is anchored, if it’s not loop back until it is. Once it is run something else.

I was thinking a repeat until loop or a for loop but I didn’t know how to go around to there. I’m new to scripting kinda, so forgive me if it’s clear as day.

1 Like

try

local foundUnAnchored = true
while foundUnAnchored == true do
foundUnAnchored = false
for i,v in pairs(model:GetDescendants()) do
if v:IsA("BasePart") then
if v.Anchored == false then
foundUnAnchored = true
end
end
end
end
print("everything anchored")

theres prob another method but this is the one I thought of

1 Like

I had to edit a few things but it works thank you!

1 Like

np! I had a few errors cuz I was rush typing before a match lol
glad it works!

1 Like
local Workspace = workspace
local Model = Workspace.Model

for _, Child in ipairs(Model:GetDescendants()) do
	if not (Child:IsA("BasePart")) then continue end
	if not Child.Anchored then continue end
	print(Child.Name) --First anchored child.
end