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

How do I fix "Humanoid Isn't a valid member of Player"?

Asked by
DrShibe 17
7 years ago

I have this issue where it says "Humanoid isn't a valid member of player" It is in a localscript and this is what I have

local player = game.Players.LocalPlayer
s = player.Humanoid
while true do
script.Parent.Text = s.Parent.Name
wait()
end

Basically, I have a ScreenGUI that has a textlabel and then this is a localscript is located inside of the textlabel.

0
You're missing 'Character' Probix 80 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

Humanoid is apart of the Character, not the Player

We can get the Character by doing player.Character. You can use .Character on any player to get the character. Sometimes the Character hasn't loaded though, so you would wait for the event CharacterAdded to fire. Example,

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local s = char:WaitForChild("Humanoid")
while wait() do
    script.Parent.Text = s.Parent.Name
end
I also used WaitForChild on the Humanoid, and changed the loop for the wait to be in the while loop to make things smaller.

Good Luck!

If I helped, please don't forget to accept my answer!
Ad

Answer this question