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

Changing size every 1 second?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

I have a script inside the part and I want the part to change its size in the x value every second.

x = script.Parent
Size = script.Parent.Size.Vector3.new = (1,1,1)

while true do
    wait(1)
    x.Size = Size +10 
end

2 answers

Log in to vote
2
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

Your problem immediately starts on line two, Vector3 is not a valid member of size. Also, the script thinks you're trying to define the size of the brick, what I am guessing is you're trying to make the brick start off with a size of 1, 1, and 1. Also Vector3.new() does not need a equal size since it kind of is a function.

x = script.Parent
x.Size = Vector3.new(1,1,1)

In the script so far, you have defined the part as x, now that you have that you can change the Size property of it to 1, 1, 1. Now for your while loop, you want it to change size every second, but the part can only reach 2048, 2048, 2048 in size, so we'll have the loop grow slowly. We'll need to start the loop, since we know the end result being 2048 we can use a for loop, that way when the script is done you won't get lagged.

x = script.Parent
x.Size = Vector3.new(1,1,1)

for i=1, 2048 do --for every index value between 1 and 2048 the part will grow.
    x.Size = Vector3.new(i,i,i) --index is i, so those will be the arguments in the Vector3 value. The part will grow 1 stud each time in the loop.
    wait(1)
end

There is a third argument for for loops that will allow you to set a increment of how much the number goes up, so we can put 1, 2, 4, anything a factor of 2048 will do. So for line four you can put

for i=1, 2048, 2 do

to go up by increments of 2, and change that 2 to anything you need it to be to go up by that certain increment.


Answer your question? Hit the accept answer button next the the post.
Just helped? Hit the upvote button next to this post.
Ad
Log in to vote
2
Answered by
funyun 958 Moderation Voter
8 years ago
part = script.Parent
--Line 2 in your script is totally unnecessary.

while wait(1) do --A little trick to make the loop one line shorter.
    part.Size = part.Size + Vector3.new(1, 1, 1) --The part's size will be itself plus 1 on each axis.
end

Answer this question