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?
01 | while wait() do |
02 | for index, child in pairs (game.Workspace.Lawn:GetChildren()) do |
03 | if child.Size.Y ~ = 2.4 then |
04 | child.Size = child.Size + Vector 3. new( 0 , 0.2 , 0 ) |
05 | else |
06 | child.Size = child.Size + Vector 3. new( 0 , 0 , 0 ) |
07 | end |
08 |
09 | child.CanCollide = true |
10 | child.Anchored = false |
11 | wait( 0.05 ) |
12 | child.CanCollide = false |
13 | child.Anchored = true |
14 | end |
15 | wait( 10 ) |
16 | 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
01 | while wait() do |
02 | for index, child in pairs (workspace.Lawn:GetChildren()) do |
03 | if child.Size.Y > = 2.4 then |
04 | child.Size = child.Size + Vector 3. new( 0 , 0.2 , 0 ) |
05 | child.CFrame = child.CFrame + CFrame.new( 0.0.1 , 0 ) --Bringing it up half of what the size increased |
06 | else |
07 | child.Size = child.Size + Vector 3. new( 0 , 0 , 0 ) |
08 | end |
09 |
10 | child.CanCollide = true |
11 | child.Anchored = false |
12 | wait( 0.05 ) |
13 | child.CanCollide = false |
14 | child.Anchored = true |
15 | end |
16 | wait( 10 ) |
17 | 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 >
.1 | 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".