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
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)
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.
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.
Again my sincere apology.