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

How do I assign a Y value to a part?

Asked by 9 years ago

I have 8 parts indexed by "for _, v in pairs". I've tried simply going like "v.Position.Y = 150" and v.Position.Y = Vector3.new(0,150,0).

2 answers

Log in to vote
1
Answered by 9 years ago

If you want to assign a value to the parts but you want the X axis and Z axis on the 3-D plane to be a same just do this.

local Parts = {}

for i, v in next,(Parts) do
    v.Position = Vector3.new(v.Position.X,150,v.Position.Z)
end

Now the Y axis for the Array parts will all be 150 :D

Ad
Log in to vote
1
Answered by 9 years ago

When you use a position or anything that has more than one value to it, it can use Vector3, Vector2, UDim2, ect. You almost have it down but you don't do "v.Position.Y", it is assigned the Y value in the Vector3.

for _, v in pairs(parts) do
    v.Position=Vector3.new(0,150,0)
end

Vector3 is used to assign the x,y, and z values all at once. part.Position=Vector3.new(X Position, Y Position, Z Position)

0
And that won't make my x and z position be 0? Ethan_Waike 156 — 9y

Answer this question