Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Timed and repeat for ever anchor and unanchor?

I want,that a model with some parts inside,Anchor and unanchor for ever,im using that script

function check(model)
	for i, part in pairs(model:GetChildren()) do
		if part.ClassName == "Model" then
			
			while true do
			
			check(part) 
		elseif part.ClassName == "Part" then
			
		
			
			part.Anchored = true
			wait (4)
			part.Anchored = false
			
		end
	end
end

check(script.Parent)

1 answer

Hi Spring,

You misplaced the while loop in that script. You just needed to loop through the call of the function. So, only check(script.Parent)Here, I polished it a bit and placed the while loop correctly. This is how it should be:

local function anchor_unanchor_forever(model)
	for _, part in next, model:GetChildren() do
		if part.ClassName == "Model" then
			anchor_unanchor_forever(part);
		elseif part.ClassName == "Part" then
			part.Anchored = true;
			print(part.Anchored)
			wait(4)
			part.Anchored = false;
			print(part.Anchored)
		end
	end
end

while wait() do
	anchor_unanchor_forever(script.Parent);
end

##Hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

1 comment

0

while wait() do lol

This discussion is preserved as it was. New answers, comments, and votes are closed.