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

How do I edit the size of a brick on a loop?

I want to create a for loop that increases the size of a brick by 1 in each direction 10 times. Thus far I have

local brick = Instance.new("Part")
brick.Parent = game.Workspace
brick.Size = Vector3.new(2,2,2)
brick.Name = "brick"
local brack = script.Parent.brick

for i = 1, 10 do

I do not know what to put at line 6. I know if I was working with a Vector3 value then I could assign each value to a variable, but with a brick size I do not know how to specify each value in the bricks size.

1 answer

✓ Accepted answer

Well that is fairly simple. All you have to do is a repeat loop.

derp = 0 -- declare this variable before the function and events
local brick = Instance.new("Part")
brick.Parent = game.Workspace
brick.Name = "brick"
brick.Size = Vector3.new(2,2,2)-- This is the current size for the brick

repeat 
	brick.Size = brick.Size + Vector3.new(1,1,1)  --This is the amount the size will increase
	derp = derp+ 1
until  derp == 10


This will essentially repeat the loop 10 times. You can change derp or the number 10 to what ever you want, just try to use the same script structure. you can also change the wait time so you can witness the events in action.

****Hopes this helps you :D. there may be other ways to do this but i find this the easiest

2 comments

0

Thank you, that worked! However because I am big noob I dont know how to mark this post as answered

0

dont worry, i dont know how to do mines either xD

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