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

How do I get the humanoid for all players in game?


function prepPlayer()
	local children = game.Players:GetChildren()
	for i = 1, #children do
		hum =	children[i].Character:WaitForChild("Humanoid")
		hum.WalkSpeed = 30
	end
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.

1 answer

✓ Accepted answer

There doesn't appear to be anything wrong with your code with the exception of a few gotchas and nil checks

function prepPlayer()
    local children = game.Players:GetPlayers()
    for i = 1, #children do
        local hum =  (children[i].Character or children[i].CharacterAdded:wait()):WaitForChild("Humanoid")
        hum.WalkSpeed = 30
    end
end

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