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

What am I doing wrong Im trying to define a humanoid and its not working?

Asked by 6 years ago

Okay so this Server Script is inside ServerScriptService and im trying to define a Humanoid by using the parent method but it keeps giving me a error that its not a valid member of data model

heres the script

hum = script.Parent.Parent.Humanoid
print(hum)

1 answer

Log in to vote
1
Answered by 6 years ago

You want to let it print the Name of the humanoid if you want to use print()

hum = script.Parent.Parent.Humanoid
print(hum.Name)

But, a Humanoid inside of a players character would not be any parent of ServerScriptService. The serverscriptservice is only parented by "game".

If you want the player's humanoid, do this:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function()
        local hum = player.Character:WaitForChild("Humanoid")
        print(hum.Name)
    end)
end)
Ad

Answer this question