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

How to randomize part orientation?

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))

1 answer

✓ Accepted answer

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.

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