I am using tweenservice to rotate a part when a specific action occurs. The part does rotate, but it rotates in the same direction instead of random directions each time. How do I properly randomize orientation?
local tweeninfo = TweenInfo.new(1) ts = game:GetService("TweenService") local goal = {} goal.Size = Vector3.new(0, 0, 0) goal.Orientation = Vector3.new(math.random(-90,90),math.random(-90,90),math.random(-90,90))
Use CFrame.Angles
. Here's an example;
goal.CFrame = part.CFrame * CFrame.Angles(math.rad(math.radnom(-180,180)),math.rad(math.radnom(-180,180)),math.rad(math.radnom(-180,180)))
math.rad()
just converts the numbers to radians.