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

Why cant i access the humanoid?

Asked by 5 years ago

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)
0
why script.Parent.Parent when you have the player already? player.Character.Humanoid.WalkSpeed hellmatic 1523 — 5y
0
i tried that and i still got humanoid is not a valid member of model Gameplayer365247v2 1055 — 5y

1 answer

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
5 years ago

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)
0
thanks it worked finaly Gameplayer365247v2 1055 — 5y
Ad

Answer this question