Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Vector3 Orientation not changing?

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.

2 comments

0

one question, why is a kiSPHERE a cylinder?

0

Not relevant to the problem.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.