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

Workspace.Script:8: attempt to index nil with 'Humanoid' a server script help?

while true do wait() player = game.Players:GetChildren() for i = 1, #player do if player[i].TeamColor ~= game.Teams.SCP.TeamColor then if player[i].Character.Humanoid.WalkSpeed > 50 or player[i].Character.Humanoid.Health > 5000 or player[i].Character.Humanoid.MaxHealth > 5000 then player[i].Character.Parent = nil player[i].Parent = nil wait(3) end end end end

1 answer

while true do -- Infinite loop
	wait() -- To prevent a lag spike
	player = game:GetService("Players"):GetPlayers() -- Same as GetChildren but instead filters it to only Players.
	for i = 1, #player do -- For loop
		if player[i].TeamColor ~= game:GetService("Teams").SCP.TeamColor then -- Is the player not the same color as the SCP team
			if player[i].Character.Humanoid.WalkSpeed >= 50 or player[i].Character.Humanoid.Health >= 5000 or player[i].Character.Humanoid.MaxHealth >= 5000 then -- Is the player does meet the conditions above.
				player[i]:Kick() -- Kick the player
				wait(3) 
			end 
		end 
	end 
end

What you are doing is trying to parent the player to nil which is not possible. I also recommend using GetPlayers and GetService so that it can still be retrieved even though the name is changed. I recommend to instead change it to player[i]:Kick()

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