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

Timed and repeat for ever anchor and unanchor?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

0
while wait() do lol User#19524 175 — 5y
Ad

Answer this question