When I try to get the HumanoidRootPart it keeps giving me an error saying that it isn't a member of the model. Can someone tell me what I'm doing wrong?
local cam = workspace.CurrentCamera local offset = Vector3.new(10,50,10) local player = game.Players.LocalPlayer local runService = game:GetService('RunService') local function cameraManipulation() local character = player.Character or player.CharacterAdded:Wait() local playerPosition = character.HumanoidRootPart.Position local cameraPosition = playerPosition + offset cam.CameraType = 'Scriptable' cam.CoordinateFrame = CFrame.new(cameraPosition, playerPosition) * CFrame.Angles(math.rad(10),math.rad(-10),math.rad(0)) end runService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, cameraManipulation)
You can try Making it wait until HumanoidRootPart Is Avaliable, here is the script:
local cam = workspace.CurrentCamera local offset = Vector3.new(10,50,10) local player = game.Players.LocalPlayer local runService = game:GetService('RunService') local function cameraManipulation() local character = player.Character or player.CharacterAdded:Wait() local HRP = character:WaitForChild("HumanoidRootPart") local playerPosition = HRP.Position local cameraPosition = playerPosition + offset cam.CameraType = 'Scriptable' cam.CoordinateFrame = CFrame.new(cameraPosition, playerPosition) * CFrame.Angles(math.rad(10),math.rad(-10),math.rad(0)) end runService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, cameraManipulation)