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

How can I make a part rotate to face the player only on its Y axis?

How can I make a part rotate to face the player only on its Y axis? I know there are ways to make a part rotate to face a player, but I am not quite sure how to limit it to only the Y rotation axis.

I could set it manually with CFrame, but then I would have to figure out the math on how to make the object face the player. Any ideas?

1 answer

✓ Accepted answer

Trigonometry to the rescue!

local delta = part.Position - character.Torso.Position
local angleY = math.arctan2(delta.z, delta.x)

https://en.wikipedia.org/wiki/Tangent

https://en.wikipedia.org/wiki/Atan2

1 comment

0

Thanks, I made a few changes and implemented it and it works! But, how would I go about making it look at the camera? I have tried many variations involving the CurrentCamera's CFrame.p, but its producing a weird effect.

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