How can I make a compass gui?

How can I make a sort of compass gui which the gui moves to the position of the object.
Here’s a game which uses this:

So in summary I want a gui to move toward to an object like in the game above. So how can I do this?
Thank you in advance

Calculate the angle between the player and the target using math.atan2, then set the GuiObject.Rotation of a compass needle ImageLabel.

local function getSubjectPosition()
     return game.Players.LocalPlayer.Character.PrimaryPart.Position
end

local function getTargetPosition()
    return workspace.Target.Position
end

local function updateCompass()
    local diff = getTargetPosition() - getSubjectPosition()
    needle.Rotation = math.atan2(diff.X, diff.Y)
end

game:GetService("RunService").RenderStepped:Connect(function ()
    updateCompass()
end)
1 Like

But how can I make it move instead of just point to it? Like in the game?

Dunno what you mean, I reckon a lot of people aren’t gonna bother playing a game to find out what you mean. You should put effort into describing what you’re trying to make and how it should work, rather than expect people give advice on copying a mechanic from a game you linked.

1 Like

Sorry, it’s that it’s very hard to explain. I’ll try my best again here’s a picture I hope it will help. Sorry again I didn’t realize that.


So in summary when the character moves I want the gui object X axis also move to the object x axis. I really hope it helps.
Here’s a video too:
robloxapp-20211117-1720559.wmv (685.0 KB)

Again my sincere apology.

Here’s another example:


As you can see the gui position moves to the object. So I want the gui to move to the object x axis.