1 | function prepPlayer() |
2 | local children = game.Players:GetChildren() |
3 | for i = 1 , #children do |
4 | hum = children [ i ] .Character:WaitForChild( "Humanoid" ) |
5 | hum.WalkSpeed = 30 |
6 | end |
7 | end |
How do I get the humanoid for all players in game? This is what I have, and I can't figure out what is wrong with the script.
There doesn't appear to be anything wrong with your code with the exception of a few gotchas and nil checks
1 | function prepPlayer() |
2 | local children = game.Players:GetPlayers() |
3 | for i = 1 , #children do |
4 | local hum = (children [ i ] .Character or children [ i ] .CharacterAdded:wait()):WaitForChild( "Humanoid" ) |
5 | hum.WalkSpeed = 30 |
6 | end |
7 | end |