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

How do you limit a growing part script?

Hi, so I have made a growing part script but I dont want it to continue growing. I want it so once it reaches a certain limit, it stops. What is needed to be added to my script?

while wait(60.0) do
	script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1)
end

Thank you. And I do know that I need to use repeat in this.

1 comment

0

Couldn't you just change the wait(60) to something smaller, so the loop stops... If you want the part to be 20+ bigger than it's original size then have wait(20), cause every second it will grow by +1, so 2 seconds will mean it's grown an extra +2..

1 answer

✓ Accepted answer

The easier way to do this is to use a repeat until loop.

repeat -- Repeat the following code
    wait(60)
    script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1)
until someCondition -- You can change this however you like, the loop will stop once this value is true

If you wish to continue using a while loop, you can use break to stop the loop's execution.

while wait(60.0) do
    script.Parent.Size = script.Parent.Size + Vector3.new(1,1,1)
    if someCondition then  -- You can change this however you like, the loop will stop once this value is true
	break -- This stops the exection of the loop
    end
end

Repeat-Until Loops

Break

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