Alright,
Let's just first say that (if you wouldn't understand it from the question) I'm a bit of a noob to scripting. I know the basics but not much more so please explain what your code/answers mean in simple language.
Now to my question; I've been searching the internet far and wide and had trouble really finding a good answer, so I'm asking here: Is there a good simple way to check the angle between two objects or lookVectors. What I've found is that people seem to be using math.atan, and since I don't know trigonometry I have no idea how to use this myself. I'd be super happy if someone could either generally explain what ways there are to do this or explain to me how the more complicated ways work. I tried converting a lookVector using toEulerAnglesXYZ() and whatever I did didn't work, so if you think this could be useful for me, I'd love it if you described how to use it.
Thanks in advance! :D
So I actually managed to solve this myself. After doing some more digging on the wiki and devforums I managed to put together this piece of beautiful code:
function findRotation() local direction = game.Workspace.Camera.CFrame.lookVector local heading = math.atan2(direction.x, direction.z) heading = math.deg(heading) heading = (heading + 0.5) - (heading + 0.5) % 1 heading = heading + 180 print(heading) end
Whenever the findRotation() function is called it will print a number from 0 to 360. This number is of course dependent on where you look. Looking straight forward will give 0, 90 degrees to the right will give 270, 90 to the left will give 90 and so on. I hope this helped any future noobs looking to make their own compass or anything else that you want to use this for!
//LetsGoRobloxia