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

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

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

2 answers

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

1 comment

0

Line 5 would error, since you cannot add CFrame values. Change it to + Vector3.new(0, 0.1, 0)

###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 >.

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

2 comments

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?

0

I don’t know.

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