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

my loop doesnt work?

im just a newb that tries to code so for training i made a loop that makes grow the block every second. but after first one it stops. why it isnt looping?

local x = 1
local y = 1
local z = 1
local tag = Instance.new("Part")
tag.Name = "Block"
tag.BrickColor = BrickColor.new("Bright red")
tag.Material = "Wood"
tag.CanCollide = true
tag.Parent = workspace
tag.Position = Vector3.new(0,10,5)
tag.Size = Vector3.new(x,y,z)
local loop = 1
while (loop >= 1) do

  wait(1)

tag.Size = Vector3.new(x ,y + 1 ,z )	

end

1 comment

0

the loop works but saying "y+1" doesn't change anything. you would have to say y=y+1. if y was 2, you are like constantly asking "what is 2+1, what is 2+1..." but its always 3. refer to the answers.

3 answers

✓ Accepted answer

Just write

while true do
	y = y + 1
	wait(1)
	tag.Size = Vector3.new(x, y, z)
end

Variable 'Y' is constant and it'll always be 1.

Here's what you can do to resolve this problem:

-- By the way, since you want the loop to be infinite, you could also use the condition as true, which makes it loop infinitely.

while (true) do
      wait(1)
      y = y + 1
      tag.Size = Vector3.new(x, y, z)
end

thanks for all answers. will keep working for being good coders like you

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