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

Adding to X value of Orientation doesn't work with script?

Hello, My script is simple, to serve as a alteritive to rotation scripts, however, it doesn't work. My script: part = script.Parent

while true do
wait(0.1) 
part.Orientation.X = Vector3.new(part.Orientation.X + 0.1)
end

I don't understand why my script is not working properly and intended.

Help is appriciated.

Thanks,

1 comment

0

You should be using CFrame instead of Vector3 for this as they are intended for rotating parts. If you delete the part.Orientation.X line and replace it with part.CFrame = part.CFrame * CFrame.Angles(0,0.1,0) it will work.

1 answer

✓ Accepted answer

Your script isn't working since it has these fundamental flaws:

  • Setting BasePart.Orientation.X does not change the orientation of the part itself. BasePart.Orientation.X is just the X property of the Vector3 returned.
  • Since BasePart.Orientation is a Vector3, you must provide all three arguments in it's constructor as such: Vector3.new(x, y, z)

To fix this, you can add a Vector3 to the orientation Adding Vector3s and use the X property of the same X property of Vector3s


Finally to write the script, this should do whatever you're trying to achieve:

Script using orientation:

while true do
	wait(0.1) 
	part.Orientation = part.Orientation + Vector3.new(0.1, 0, 0)
end

Also, as commented on your post and mentioned by the wiki,

For better control over the rotation of a part, it is recommended that BasePart.CFrame is set instead

Script using CFrames:

while true do
	wait(0.1) 
	part.CFrame = part.CFrame * CFrame.Angles(math.rad(0.1), 0, 0)
end

Please comment if you have questions or I have made a mistake


Useful links and articles:


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