16:16:42.472 - HumanoidRootPart is not a valid member of Player

Why is this error coming up 16:16:42.472 - HumanoidRootPart is not a valid member of Player

This is a local script inside a gui.
This is a radar gui script

line of code which had the error

FakeCam.CFrame = CFrame.new(game.Players.LocalPlayer.Character.HumanoidRootPart.Position + Vector3.new(0,50,0),game.Players.LocalPlayer.Character.HumanoidRootPart.Position)

Whole of code

local CircularMap = game.ReplicatedStorage.CircularMap:Clone()
CircularMap.Parent = workspace

local FakeCam = Instance.new("Camera")
FakeCam.Parent = script.Parent
FakeCam.CameraType = Enum.CameraType.Scriptable

script.Parent.Adornee = CircularMap.PrimaryPart
script.Parent.ViewportFrame.CurrentCamera = FakeCam
local b = game.Workspace.Map:Clone()
b.Parent = script.Parent.ViewportFrame


while true do
	CircularMap:SetPrimaryPartCFrame(workspace.CurrentCamera.CFrame*CFrame.Angles(math.rad(90),0,0)*CFrame.new(-10,-10,-10))
	FakeCam.CFrame = CFrame.new(game.Players.LocalPlayer.Character.HumanoidRootPart.Position + Vector3.new(0,50,0),game.Players.LocalPlayer.Character.HumanoidRootPart.Position)
	game:GetService("RunService").RenderStepped:Wait() 
end

HumanoidRootPart is a member of the player’s character, not the player itself. Make sure you’re doing player.Character.HumanoidRootPart instead of player.HumanoidRootPart.

I think you should see if the player actually has a character at that point in time, and whether or not that character has a HumanoidRootPart

local LocalPlayer = game.Players.LocalPlayer
while true do
    if LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then
        CircularMap:SetPrimaryPartCFrame(workspace.CurrentCamera.CFrame*CFrame.Angles(math.rad(90),0,0)*CFrame.new(-10,-10,-10))
	    FakeCam.CFrame = CFrame.new(game.Players.LocalPlayer.Character.HumanoidRootPart.Position + Vector3.new(0,50,0), LocalPlayer.Character.HumanoidRootPart.Position)
    end
    game:GetService("RunService").RenderStepped:Wait()
end
2 Likes

Btw I get this 16:38:51.139 - Charater is not a valid member of Player

How would you be getting that from my script? I have a condition on the third line that checks if the player actually has a character.

Yes I’m confused aswell (30 char)

Next time read the post before giving any sort of response. Your response gives a clear lack of reading as OP never mentioned a player.Character anywhere and the post isn’t edited to prove it.

@OP,
I’d recommend trying to have a var WFC on the HumanoidRootPart just to see if it’ll pick it up and use it instead.

local Humanoid = player.Character:WaitForChild('HumanoidRootPart')
2 Likes

wdym that the OP never mentioned a player.Character, it’s literally in the first code block in the message. Also, the title of the post (and his error) is “HumanoidRootPart is not a valid member of Player,” and I’m explaining to him what his error means.

Next time read the post before giving any sort of response. Your response gives a clear lack of reading as OP never mentioned a player.Character anywhere and the post isn’t edited to prove it.

I would refrain from making comments like these before fully reading the OP’s post. Not only is it flat out wrong, but it’s also off topic and doesn’t help anyone.

Re-read what you posted one more time, then re-read the OP post and find your mistake. Not gonna continue this before flags come in play.

The reason you got that error is because he misspelled ‘Character’ in the first check.
image

2 Likes

Like I said, it’s off-topic and doesn’t help anyone. If you want to argue about this then send a private message.

Again, I’m just explaining what his error (“HumanoidRootPart is not a valid member of Player”) means, not fully solving his problem. It’s still completely relevant.

edit 2: Even if he later got “Charater is not a valid member of Player,” (which I didn’t see because it was posted after my first response) my original post tells him to make sure he’s doing player.Character.HumanoidRootPart.

Actually realized I never fully finished explaining what I originally put on you, my bad.
OP never mentioned a player.HumanoidRootPart in his code which is what you try to mention he did.

3 Likes

Thank you for letting me know! I have fixed the script.

3 Likes