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

How would I change the size of a part in a certain direction?

Asked by 9 years ago

I've tried to figure this out many times and I just can't seem to do it. I know that this code below:

part = script.Parent

for i = 1,10,1 do
    part.Size = Vector3.new(part.Size.X + 1,part.Size.Y,part.Size.Z)
    wait(0.1)
end

-changes the size of the part but it changes in the direction of negative X and positive X, but I just want it to change only on the direction of positive X. How could I do that?

0
Go here for help http://wiki.roblox.com/index.php?title=API:Class/BasePart/Resize The first parameter is the side, which is 0 - 5, the second part is how many studs\ legobuildermaster 220 — 9y
0
That didn't really help. alex_ander 163 — 9y
0
Try using part:Resize(0, 1) or part.Resize(0, 1) legobuildermaster 220 — 9y
0
It worked but it's only resizing it by 1. I want it to resize now by 0.2. alex_ander 163 — 9y
View all comments (2 more)
0
Then just write 0.2 instead of 1..... Scriptree 125 — 9y
0
Ugh so dumb, it only works with whole numbers. alex_ander 163 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago
local Part = script.Parent
local AddNumber = 1 --The amount of studs added in each loop.
local SizeAddition = 10 --How many times the script adds "AddNumber".

for i = 1,SizeAddition do
    wait()  
    Part.Size = Vector3.new(Part.Size.X + AddNumber,Part.Size.Y,Part.Size.Z) 
    Part.CFrame = Part.CFrame - Vector3.new(AddNumber/2,0,0)
end 

I think this is what you are looking for.

0
Finally! alex_ander 163 — 9y
0
xD ClassicTheBlue 65 — 9y
Ad
Log in to vote
0
Answered by
Scriptree 125
9 years ago

The following method will work:

local part = script.Parent

for i = 1, 10 do -- u dont need the "1" after the 10, because it already goes up by ones without that
    part.Size = part.Size + Vector3.new(1, 0, 0)  -- so here you are making the Size of the part the same, but just adding to the x, or y, or the z axis, this adds 1 stud every 1/30 seconds to the x axis
    wait() -- wait() is the least wait you can have in a server script which is also equivalent to wait(1/30)
end

Hope it helped :)

Answer this question