Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

HumanoidRootPart is not a valid member of Character?

So I have a mini map, But it should work, But for some reason in the output its saying that HumanoidRootPart isn't a valid member of Character? Here is the Local script:

local CircularMap = game.ReplicatedStorage.CircularMap
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

workspace.Map:Clone().Parent = script.Parent.ViewportFrame

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

Also, if you wondering where i says HumanoidRootPart is on line 14, Thanks.

2 answers

An easy way to fix this problem is to listen for the character until it loads in:

game.Players.LocalPlayer.CharacterAdded:Wait()

You can then check to see if the HumanoidRootPart exists:

if game.Players.LocalPlayer.Character.HumanoidRootPart then

An easy but pretty good solution to your problem.

I often had this same problem with the humanoid. I think the problem is that the player loads before the character does. So just add a line to wait until the character loads to run your script:

  repeat wait() until game.players.localplayer.character ~= nil and game.players.localplayer.character:FindFirstChild("HumanoidRootPart")  ~= nil

3 comments

0

If i mis-capitalized or misspelled something it is because i am on a phone

0

-1 for suggesting polling over events.

0

Ok but it would have worked

This discussion is preserved as it was. New answers, comments, and votes are closed.