Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

HumanoidRootPart is not a valid member of model?

Asked by 5 years ago

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)
0
Try using character:WaitForChild("HumanoidRootPart").Position lasquinceletras 38 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
Ad

Answer this question