How to tell which Direction the Player is Looking at

Hey there developers,

I’ve been trying to create some arms seen in the image below:

They are just two parts weldconstrainted to the HumanoidRootPart

But I don’t know how to make them face in the direction of where the player is looking at,
Thanks a lot!

1 Like

Local script:

local camera = game.Workspace.CurrentCamera

-- Function to get and print the look direction
local function printLookDirection()
    local lookVector = camera.CFrame.LookVector
    print("Look Direction: ", lookVector)
end

-- Example of calling the function in a loop, e.g., once per second
while true do
    printLookDirection()
    wait(1)
end

You can also use heartbeat or run service to continually get position

its acting weird now

1 Like

Try using camera.CFrame:ToOrientation and see if that would help? Like setting the weld’s CF to CFrame.Angles(camera.CFrame:ToOrientation()).

1 Like

Try implementing

camera:GetPropertyChangedSignal("CFrame"):Connect(updatePartsDirection)
1 Like
local function UpdatePartsDirection()
    local player = game.Players.LocalPlayer
    local camera = game.Workspace.CurrentCamera

    local lookVector = camera.CFrame.LookVector

    part1.CFrame = CFrame.new(part1.Position, part1.Position + lookVector)
    part2.CFrame = CFrame.new(part2.Position, part2.Position + lookVector)
end

game:GetService("RunService").RenderStepped:Connect(UpdatePartsDirection)

If these two added arms are to stay like that all the time. You may be able to just weld them in place and leave it at that.