My issues :
Hello I am currently trying to make a compass for my game which will guide’s players to secret location. But I don’t know how should i do it. Is this even possible?
Image :
The image above shows what I am trying to achieve. There is barely any solutions on youtube to I have to count on you guys. Please help me !
Are you hoping for a GUI to point to a world position?
Not I want they compass hand to show where they are.
un1ND3X
(ice)
April 29, 2020, 4:15am
#4
are you trying to do this :
or this ?
You can CFrame the compass needle to face the direction of the location.
Here’s a very simple proof of concept:
local Needle = workspace.Needle
local Target = workspace.Target
while wait() do
Needle.CFrame = CFrame.new(Needle.Position, Vector3.new(Target.Position.X, 0, Target.Position.Z))
end
https://gyazo.com/ecadb0b160d7cfc847e1564f0ac16c2d
2 Likes
Use this code as a reference
compass.CFrame = CFrame.new(compass.CFrame.p,pos2)
1 Like
The 2nd one I want. I want compass point towards it.
Is there any other way to do this without while loop?
I will surely look onto that. Thanks.
Not that I can think of. You can make it more efficient by only running when the player has the compass out and/or increasing the wait time.
un1ND3X
(ice)
April 29, 2020, 4:27am
#11
or using a while true do loop and calling wait(n) after that instead.
EDIT (08/09/2021): Yes, I’ve actually started seeing while task.wait(). Just so it’s clear, the document does cover yielding functions being used as conditions as well. task.wait() is not a better replacement and also falls under discouraged practice as per the below.
Introduction
Earlier today on my usual camp-out by the Scripting Support category, I stumbled across a piece of code that set off my nitpick ringer and reminded me of a document I stumbled across long ago. Today, after being prom…
2 Likes
Alright thank you guys for reply. I will try to make it much more efficient with the sources you guys provided.
MayorGnarwhal:
local Needle = workspace.Needle
local Target = workspace.Target
while wait() do
Needle.CFrame = CFrame.new(Needle.Position, Vector3.new(Target.Position.X, 0, Target.Position.Z))
end
How did you make the part not move around