Have arrow above player head to point towards stage

I want to have an arrow part that points towards a stage, however can’t get it to be smooth at all

-- Setup arrow
local Arrow = script:WaitForChild("Arrow")
Arrow.CFrame = Character.Head.CFrame * CFrame.Angles(0, 0, math.rad(90)) + Vector3.new(0, 4, 0)
Arrow.WeldConstraint.Part0 = Character.Head

Arrow.Parent = Character.HumanoidRootPart

Arrow.Anchored = false

--// Update the arrow
local function UpdateArrow()
	Arrow.CFrame = CFrame.new(Arrow.Position, workspace.Stages["1"].Position)
end

RunService.Stepped:Connect(UpdateArrow)

In the API Reference: WeldConstraint | Roblox Creator Documentation
It states:
Roblox handles moving a welded part differently depending on whether the part was moved using its Position or with its CFrame .

If a welded part’s Position is updated, the part will move but none of the connected parts will move with it. The weld will recalculate the offset from the other part based on the part’s new position.

You are moving the whole character when you set the Arrow’s CFrame. (Not gud)

Instead of changing the CFrame, try figuring out a way to change orientation. Let me try to figure it out myself, rq.

In the first three arguements of CFrame.new (lookAt) If you print it, it shows the orientation of the specific part. Now, You can use a string.split:

print(string.split(tostring(CFrame.new(Arrow.Position, workspace.RandomPart.Position)), ", "))

You can then use the first three arguements:

local Info = string.split(tostring(CFrame.new(Arrow.Position, workspace.RandomPart.Position)), ", ")
Arrow.Orientation = Vector3.new(Info[1], Info[2], Info[3])

And boom, CFrame to orientation.

how bout just doing that

-- Setup arrow
local Arrow = script:WaitForChild("Arrow")

Arrow.Parent = Character.HumanoidRootPart

Arrow.Anchored = false

--// Update the arrow
local function UpdateArrow()
	Arrow.CFrame = CFrame.new(Character.Head.Position+Vector3.new(0,2.5,0), workspace.Stages["1"].Position)
end

RunService.Stepped:Connect(UpdateArrow)
1 Like

Quoted from the API Reference:
In contrast, if a part’s CFrame is updated, that part will move and any part welded to that part will also move. These other parts will be moved to make sure they maintain the same offset as when the weld was created.

You’re changing the CFrame of the part constantly, aka moving the character. Which, in this case, is not good.

If you did:

local Arrow = script:WaitForChild("Arrow")
Arrow.CFrame = Character.Head.CFrame * CFrame.Angles(0, 0, math.rad(90)) + Vector3.new(0, 4, 0)
Arrow.WeldConstraint.Part0 = Character.Head

Arrow.Parent = Character.HumanoidRootPart

Arrow.Anchored = false

--// Update the arrow
local function UpdateArrow()
	local Info = string.split(tostring(CFrame.new(Arrow.Position, workspace.RandomPart.Position)), ", ")
    Arrow.Orientation = Vector3.new(Info[1], Info[2], Info[3])
end

RunService.Stepped:Connect(UpdateArrow)

This would NOT change the character’s position, effectively not flinging them to the surface of the moon.

How can I remove the delay?

There’s kind of a delay between updating position and it looks bad

1 Like

try changing

RunService.Stepped:Connect(UpdateArrow)

to

RunService.RenderStepped:Connect(UpdateArrow)

im not sure if there is any difference but thats the only thing i could think of

I get a weird rotation on it? I am facing towards the part the arrow should be facing, however it kinda faces upwards

Made a stupid mistake, first three is position, I can’t seem to find rotation now, kinda weird. Gimme a moment to figure this out.

You can also use a motor6d and use Transform to rotate the arrow.

local offset = Vector3.new(0, 5.5, 0)

local arrow = script:WaitForChild("Arrow")

local motor6d = Instance.new("Motor6D")
motor6d.Part0 = Character.HumanoidRootPart
motor6d.Part1 = arrow
motor6d.C0 = CFrame.new()
motor6d.C1 = CFrame.new()
motor6d.Parent = arrow

arrow.Parent = Character.HumanoidRootPart

local function UpdateArrow()
	local newArrowCf = CFrame.lookAt(hrp.Position + offset, targetPart.Position)
	motor6d.Transform = hrp.CFrame:ToObjectSpace(newArrowCf)
end

RunService.Stepped:Connect(UpdateArrow)

Here I made a simple following target arrow

1 Like

https://www.roblox.com/games/7151874309/Arrow-Test

–Free to use–

2 Likes

You didn’t uncopylock???

1 Like

That causes my character to go flying off into the void. And if I make the arrow unanchored, it just falls through the world and is gone and destroyed before I’m even able to see my character

sorry i forgot, try now

Unimportant words until I exceed 33 characters

Works well! Just quick question, if I have this inside StarterCharacter, should I be unbinding the action on death, to prevent any memory leaks or what not?

Yes

runService:UnbindFromRenderStep("Input")
SetTarget(nil)
1 Like