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

Help with stopping a growing part when getting to a certain size?

I have a growing part and I want it to stop growing when it gets to a certain size.

while true do
	Part = script.Parent
	xs = Part.Size.X
	ys = Part.Size.Y
	zs = Part.Size.Z
	xp = Part.Position.X
	yp = Part.Position.Y
	zp = Part.Position.Z
	Part.Size = Vector3.new(xs+.1,ys,zs)
	wait()
	if Part.Size == Vector3.new(1,0.2,0.23) then --The real size of the part is (0.45, 0.2, 0.23)
		--How can I break the whole script from working here?
	end
end

3 comments

0

add a break

0

or use a repeat until

0

Help please?

2 answers

✓ Accepted answer

Hello there; let me get it right for you! I testes this on a .2x.2x.2 block! Here we are stopping the function WHEN the X size of part is equal to 1. Just add "and Part.Size.Y >= number" and etc if you want to change other sizes of the part

while true do
    Part = script.Parent
    xs = Part.Size.X
    ys = Part.Size.Y
    zs = Part.Size.Z
    xp = Part.Position.X
    yp = Part.Position.Y
    zp = Part.Position.Z
    Part.Size = Vector3.new(xs+.1,ys,zs)
    wait()
    if Part.Size.X >= 1 then --The real size of the part is (0.45, 0.2, 0.23)
        break -- break is used to stop loops
    end
end

1 comment

0

since you are maintain the size its easierto have them out of the loop

while true do
    Part = script.Parent
    xs = Part.Size.X
    ys = Part.Size.Y
    zs = Part.Size.Z
    xp = Part.Position.X
    yp = Part.Position.Y
    zp = Part.Position.Z
    Part.Size = Vector3.new(xs+.1,ys,zs)
    wait()
    if Part.Size == Vector3.new(1,0.2,0.23) then --The real size of the part is (0.45, 0.2, 0.23)
        break -- break is used to stop loops
    end
end

4 comments

0

Does not work

0

What is the part's size before you ran this script?

0

The script is running so fast it skips the if statement. Use a greater than or equal to( >=) to stop the code at the break. The reason this happens has something to do with computer binary or something. I don't care. That seems to be the problem though :P

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