How do i make the character rotate towards the camera? (first person & shiftlock)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    character rotating / orienting towards the camera (not looking up or down though)

  2. What is the issue? Include screenshots / videos if possible!
    roblox WOULD normally cover this, but since im using 1 custom line (to make the game look a little better), it doesn’t rotate on its own.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i’ve tried to read the devforum but nothing relevant is showing up since its such a specific issue

the line in question:

game.Workspace.Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Head")
local runService = game:GetService("RunService")

runService.RenderStepped:Connect(function()
    local character = game.Players.LocalPlayer.Character
    local camera = game.Workspace.Camera

    if character then
        local characterPosition = character.HumanoidRootPart.Position
        local cameraPosition = camera.CFrame.Position
        local lookVector = Vector3.new(cameraPosition.X, characterPosition.Y, cameraPosition.Z) - characterPosition
        local newCFrame = CFrame.lookAt(characterPosition, characterPosition + lookVector)
        character:SetPrimaryPartCFrame(newCFrame)
    end
end)

okay, i mightve miss-worded my question
when i said the character didnt rotate towards the camera, i meant only shiftlock & first person

clip of the issue:

local camera = game.Workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character
local head = character:WaitForChild("Head")

local function updateCharacterRotation()
    local lookVector = (camera.CFrame.Position - head.Position).Unit
    character:SetPrimaryPartCFrame(CFrame.lookAt(head.Position, head.Position + lookVector))
end

updateCharacterRotation()

game:GetService("RunService").RenderStepped:Connect(updateCharacterRotation)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.