Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make a script stop only for a specific child?

Asked by 6 years ago

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?

01while 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 + Vector3.new(0,0.2,0)
05else
06    child.Size = child.Size + Vector3.new(0,0,0)
07end
08 
09child.CanCollide = true
10child.Anchored = false
11wait(0.05)
12child.CanCollide = false
13child.Anchored = true
14end
15    wait(10)
16end

2 answers

Log in to vote
1
Answered by
dirk2999 103
6 years ago

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

01while 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 + Vector3.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
06else
07    child.Size = child.Size + Vector3.new(0,0,0)
08end
09 
10child.CanCollide = true
11child.Anchored = false
12wait(0.05)
13child.CanCollide = false
14child.Anchored = true
15end
16    wait(10)
17end
0
Line 5 would error, since you cannot add CFrame values. Change it to + Vector3.new(0, 0.1, 0) User#19524 175 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The thing about the ~= 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 >.

1if child.Size.Y > 2.4 then

The > 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".

0
This probably isn't related to scripting, but how can I make it so when the size changes it doesn't sink through the floor? VeryDarkDev 47 — 6y
0
I don’t know. User#19524 175 — 6y

Answer this question