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

Why cant i access the humanoid?

i made a script that prints the humanoid walkspeed but it says that the humanoid is not a valid member of model, i did also try to print the parent of the model and it says the workspace why why cant i access the humanoid. the script lies in the screengui so i got it on the client side

local player = game:GetService("Players").LocalPlayer

print(script.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed)

2 comments

0

why script.Parent.Parent when you have the player already? player.Character.Humanoid.WalkSpeed

0

i tried that and i still got humanoid is not a valid member of model

1 answer

✓ Accepted answer

You have to use WaitForChild:

local player = game:GetService("Players").LocalPlayer

print(player.Character:WaitForChild("Humanoid"))
-- WaitForChild yields the script until it finds the name in the given instance.
-- It has 2 arguments: WaitForChild(x, y) x = name of object (string) y = seconds of how long you will want it to yield (optional)

1 comment

0

thanks it worked finaly

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