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

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

Asked by 5 years ago

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,

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. Alexander_Ashford 231 — 5y

1 answer

Log in to vote
0
Answered by
Ankur_007 290 Moderation Voter
5 years ago

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: lua while true do wait(0.1) part.Orientation = part.Orientation + Vector3.new(0.1, 0, 0) end

<br> 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: lua 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:


Ad

Answer this question