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

How do I CFrame-rotate something on only one axis?

I'm currently trying to make a part go to wherever I click, which I 'm capable of doing, using CFrame.new(Mouse.Hit.p) - But, I want it to rotate with the mouse too. The mouse, suprisingly, has rotation CFrame too, as I discovered a while ago. I actually forget how I got it, but that's besides the point; I threw that part out when I couldn't figure out how to restrict it to one axis, IE, to turn it rather than to fully rotate and flip it too.

How would I go about getting the mouse's cframe, and restricting it so it only turns on one axis?

2 answers

CFrame.new (Mouse.Hit.p, Vector3.new(Mouse.Hit.p.x, Part.Position.Y, Mouse.Hit.p.z))

Use this CFrame. The first Mouse.Hit.p gives it the position that it is going to go to when you click, and then the

Vector3.new(Mouse.Hit.p.x, Part.Position.Y, Mouse.Hit.p.z)

will rotate it to the position the the mouse it looking at on the y axis.

3 comments

0

I don't know HOW it rotates it on the Y axis when you lock the Y axis to the part.position, and only change the X and Z axis. And for some reason this isn't working, it rotates them to a very weird angle - one axis turns it sideways, the other flips it on its side, and the Y axis jut turns it diagonally. (Tried them all separately.. )

0

I'm using Template:SetPrimaryPartCFrame(CFrame.new(Mouse.Hit.p + Vector3.new(0,0.5,0), Vector3.new(Mouse.Hit.p.x, Template.PrimaryPart.Position.y, Mouse.Hit.p.z))) - what am I doing wrong?

0

No matter how I combine them, they seem to not even orient based on the mouse's cframe, just a static, weird angle

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