#player keeps dying when trying to lock the camera above the player

7 messages · Page 1 of 1 (latest)

fading lava
#
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

local CAMERA_DEPTH = 50

local function updateCamera()
    local character = player.Character
    if character then
        local root = character:FindFirstChild("HumanoidRootPart")
        if root then
            local rootPosition = root.Position
            local cameraPosition = Vector3.new(rootPosition.X,  CAMERA_DEPTH,  rootPosition.Z)
            camera.CFrame = CFrame.lookAt(cameraPosition, rootPosition)
        end
    end
end

RunService:BindToRenderStep("SidescrollingCamera", Enum.RenderPriority.Camera.Value + 1, updateCamera)```
#

this is the code btw

#

it also does some other weird things to the player

#

NVM

#

i fixed it

#

I just needed to add the root position for the Y axis to the camera depth

#

so it doesnt try to lock to that position all the time