So my script currently works, except for the fact that even if the parts Y size is above 2.4, it will still gain value.
How can I make it so it will stop for that specific child?
while wait() do for index, child in pairs(game.Workspace.Lawn:GetChildren()) do if child.Size.Y ~= 2.4 then child.Size = child.Size + Vector3.new(0,0.2,0) else child.Size = child.Size + Vector3.new(0,0,0) end child.CanCollide = true child.Anchored = false wait(0.05) child.CanCollide = false child.Anchored = true end wait(10) end
To your above comment question,
Changing the size changes it from the center equally.
Not sure if that makes sense but I'll try to make more sense of it,
If you change a parts size by 1
on the Y
axis, the size will increase by .5
on the top and .5
on the bottom. To correct this move the brick's CFrame
up by half
of what you increase the size
while wait() do for index, child in pairs(workspace.Lawn:GetChildren()) do if child.Size.Y >= 2.4 then child.Size = child.Size + Vector3.new(0,0.2,0) child.CFrame = child.CFrame + CFrame.new(0.0.1,0) --Bringing it up half of what the size increased else child.Size = child.Size + Vector3.new(0,0,0) end child.CanCollide = true child.Anchored = false wait(0.05) child.CanCollide = false child.Anchored = true end wait(10) end
~=
operator is that if the number is not equal to 2.4, code will run. The number can be greater or less than 2.4, as long as it's not equal to 2.4. To fix this, make your ~=
to >
.if child.Size.Y > 2.4 then
>
means "greater than", the <
means "less than", the ==
means "equal to", the ~=
means "not equal to", the <=
means "less than or equal to", and the >=
means "greater than or equal to".