Help with compass

I would like to know how I could make my compass work, pointing the arrow to a position. Does anyone have any idea how I could do this?

I would personally use welds to do this, welds can be finnicky though and you will probably have to do a lot of adjusting (the compass also has to be flat all the time for this, I can rewrite it to perhaps solve this problem is you expect it to be turning and bouncing around and such

weld.C0 = CFrame.new(-0.5,0,0)*(part0.CFrame-part0.CFrame.p):Inverse()

Youll probably have to change the (-0.5,0,0) to position it correctly on your model

Is there a way to make sure that even if the compass is not flat it still works? Because it’s a tool that players can have in their hands. Also, is it possible to change the direction of the compass? In my game the player can select an island and the compass will point to the island.

This should be more versatile, it will be a tiny bit temporarily inaccurate when not held level but that should be expected since a compass can only rotate in one axis (it also wont work if upside down but I trust this isnt a space game)

local diff = landmark.Position-compass.Position 
weld.C0 = CFrame.new(0.5,0,0)*CFrame.Angles(math.atan2(lookvector.Z,lookvector.X)-math.atan2(diff.Z,diff.X),0,0)

Once again a lot of fidgeting will be required to make it work with your specific compass model

Who is lookvector? the weld? or something else?

Oh sorry, I left that part out
The lookvector would be the lookvector of the compass body, so the actual thing you hold

The arrow does not move
Image

Can you show your code so I can see if theres a problem with it?

nvm it work! :smiley:
TYSM! :smiley:
Thank for your help

1 Like