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

Vector3 Orientation not changing?

Asked by 5 years ago

Hey guys, I'm struggling with this script where I'm trying to change this part's orientation but it ends out with no orientation change at all. here's my script:

    local KiSphere = Instance.new("Part")
    KiSphere.Name = "KiSphere"
    KiSphere.Shape = Enum.PartType.Cylinder
    KiSphere.Size = Vector3.new(0.05,8,7)
    KiSphere.Orientation = Vector3.new(0, 0, 90)
    KiSphere.Material = Enum.Material.Neon
    KiSphere.BrickColor = BrickColor.new("New Yeller")

Don't mind the fact that it's called KiSphere. I tried to change all of the orientation values one by one but no change.

Any help is appreciated, thanks.

0
one question, why is a kiSPHERE a cylinder? theking48989987 2147 — 5y
0
Not relevant to the problem. Thundermaker300 554 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Rather than setting the Position/Orientation, set the CFrame of the object.

KiSphere.CFrame = CFrame.new(x,y,z)*CFrame.Angles(x,y,z)

The code above sets two things, the position and the orientation of the object. The first chunk, the CFrame.new(x,y,z) sets the position. X, Y, and Z can be directly provided.

However, the in second section, CFrame.Angles(x,y,z), the values need to be added in radians. Luckily, we have a method for doing this, math.rad. An example of this setup would be CFrame.Angles(math.rad(90),math.rad(90),math.rad(90))

The following example would position the part 3 studs up from the origin and rotate it 180 degrees on the X axis.

part.CFrame = CFrame.new(0,3,0)*CFrame.Angles(math.rad(180),0,0)

Note that if the rotation value is 0, math.rad is optional.

Hope this helped.

Ad

Answer this question