How to make a growing part not go over max size?

i have a part that’s slowly and constantly growing in size, and i want to set the size back to the original if it ever grows more that that. i’m wondering why my script doesn’t work.
extreme beginner warning:

local o2 = script.Parent
while true do
	wait(0.2)
	if o2.Size >= Vector3.new(0.25, 3.972, 0.5) then 
		o2.Size = Vector3.new(0.25, 3.972, 0.5)
	end
end
1 Like

I think the problem is in your if statement. I’m not sure if you can compare vectors like that.
Assuming your part grows equally in size in all directions, try this:

local o2 = script.Parent
while true do
    task.wait(0.2)
	if o2.Size.X > 0.25 or o2.Size.Y > 3.972 or o2.Size.Z > 0.5 then 
		o2.Size = Vector3.new(0.25, 3.972, 0.5)
	end
end
1 Like

i forgot to mention that it only grows on the y axis, but even so this script worked nicely. thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.