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

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

Asked by 8 years ago

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

Log in to vote
4
Answered by 8 years ago

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

0
Thank you, that worked! However because I am big noob I dont know how to mark this post as answered Cookiedude42 10 — 8y
0
dont worry, i dont know how to do mines either xD koolkid8099 705 — 8y
Ad

Answer this question