Some trouble with my compass and his arrow

  1. What do you want to achieve? rotating the arrow from my compass on real time and without delay (stay inside the compass and not outside while moving with my character)

  2. What is the issue? As you could see, the arrow is following me behind my back and doesn’t stay inside the transparent sphere
    https://gyazo.com/2e8764e93ab80bc95a7810ba36a984c4

  3. What solutions have you tried so far? I did ask the developper of Square piece (for those who knows him) because he got something similar. He did tell me some tips but still can’t achieve it

So, basically, this is my tool:
https://gyazo.com/438e0faf11b21f45d102717e63481613

The localscript just open/close a GUI to pick a destination. The red part of the arrow will point the direction to follow.

the value IslPos contains the Vector3 value of the position

The script named “pointing” is the following code

local arrow = script.Parent
local sphere = arrow.Parent:FindFirstChild("sphere")
local weld = Instance.new("Weld", arrow)
weld.Part0 = arrow
weld.Part1 = sphere

for i = 0, math.huge do
	weld.C1 = weld.C1 * CFrame.new(arrow.CFrame.Position, arrow.Parent.Parent:FindFirstChild("IslPos").Value)
	wait()
end

i’ve tried to think by myself and this is the first time i ask for help. But i think that this time i can’t achieve it alone.

i would be thankfully to the one which give me a solution for my problem.

1 Like

I think you need to use something like weld constraint or a motor.

another option, (that I do not recommend) is you could use renderstepped to update it every frame.

i’ve tried to update the C1/C0 every wait into a loop but failed. Any idea how i would do that?

Also, with a weld constraint, how would i be able to move the arrow without moving the whole tool?

okay, just tested it in studio, use a weld constraint(not a weld) and weld the arrow to the handle, set the handle as part0 and arrow as part1, then just change the orientation of the arrow.

When you say handle, you mean my handle or the Handle with cap H?

oh, you have 2 handles .-. uhhh i guess that one that has the other weldconstraints in it, I mean it doesn’t really matter

Ok, now the arrow is staying inside the sphere but then, the red part doesn’t show the given position ._.

local arrow = script.Parent

for i = 0, math.huge do

arrow.Orientation = Vector3.new(arrow.Parent.Parent:FindFirstChild("IslPos").Value)

wait()

end

ps: it does rotate now thank’s

But now, there is my other problem:
https://gyazo.com/b15d3c2f430cb409572417b570c1432e

this is not showing the way (thanks to Lua breaking something when you fix something else)

local p1 = Vector3.new() --the vector3 of the object
local p2 = Vector3.new() --the vector3 of the arrow

local xOffset = p2.X - p1.X
local zOffset = p2.Z - p1.Z


local rotation = math.deg(math.atan2(zOffset, xOffset))

try setting the y orientation of the arrow to rotation, (if might need to try setting the x or z axis rather than the y)… this should point the arrow in the direction of the object you want it to point to.

like this?

local arrow = script.Parent
local val = arrow.Parent.Parent:FindFirstChild("IslPos")




for i = 0, math.huge do
	local p1 = Vector3.new(val.Value) --the vector3 of the object
	local p2 = Vector3.new(arrow.Position) --the vector3 of the arrow
	
	local xOffset = p2.X - p1.X
	local zOffset = p2.Z - p1.Z
	
	local rotation = math.deg(math.atan2(zOffset, xOffset))
	
	arrow.Orientation = Vector3.new(0, 90, 0)
	wait()
end

Lua isn’t breaking anything. A computer can only do what you tell it to. Give it the wrong instruction and you get the wrong output.

What is the value stored at

If it’s already a Vector3, then you shouldn’t put it inside a Vector3.new() call.

change

arrow.Orientation = Vector3.new(0, 90, 0)

to

arrow.Orientation = Vector3.new(0, rotation, 0)

then check if it works

okey so i tested some rotations and even if it point to right direction, the arrow isnt on the right direction
https://gyazo.com/c760cba75ad8dbae23d05cf60c5d9944
actually it does point the part in front of my character

what i also know is, the normal rotation of the arrow isn’t 0,0,0
https://gyazo.com/2f1f424a697486c1c78d8203dede5cc6

i tried to modify a bit arrow.Orientation on the script but still doesnt show the way

maybe try adding or subtracting 90 from the rotation, so something like

arrow.Orientation = Vector3.new(0, rotation - 90, 0)

without the model, I can’t give much more help.

you did give a precious help until now. I tried some rotations and the fact is, it does change for every island. If the red point the right direction for the first island, it is random for the others.

This is the actual script:

local arrow = script.Parent
local val = arrow.Parent.Parent:FindFirstChild("IslPos")

for i = 0, math.huge do
	local p1 = val.Value --the vector3 of the object
	local p2 = arrow.Position --the vector3 of the arrow
	
	local xOffset = p2.X - p1.X
	local zOffset = p2.Z - p1.Z
	
	local rotation = math.deg(math.atan2(zOffset, xOffset))
	
	arrow.Orientation = Vector3.new(0, rotation + 225, -90)
	wait()
end

I think that your help can’t go further as you are not in roblox studio with me. But you did give a precious help. Thank’s for your time