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

Needing help with brick facing random direction on X axis. Help?

Asked by 5 years ago
Edited 5 years ago

Hello, this is a simple question but I'm bad at movement stuff.

What I'm trying to do is make the brick face a random direction on the X axis but it doesn't change.

I've tried 2 things such as this:

local rot = math.random(0, 360)

script.Parent.Orientation = Vector3.new(script.Parent.Position, CFrame.Angles(rot, 0, 0))

And this:

local rot = math.random(0, 360)

script.Parent.CFrame = CFrame.Angles(rot, 0, 0)

But both of them don't seem to be working, can someone help?

1 answer

Log in to vote
3
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
5 years ago

You were quite close.

--Orientation
Part.Orientation = Vector3.new(RotX,0,0)

--CFrame
Part.CFrame = CFrame.new(Part.Position) * CFrame.Angles(math.rad(RotX),0,0)

--Or this if you want to add it to the previous rotation
Part.CFrame = Part.CFrame * CFrame.Angles(math.rad(RotX),0,0)
Ad

Answer this question