OK.
So i have a script here that’s supposed to kill off all the players in the server. But the script doesnt work. Its a server script. I have already tried waitforchild and findfirstchild, doesnt work. I get this error message:
Players.trueblockhead101.PlayerGui.Countdown.TextLabel.Script:72: attempt to index nil with ‘Humanoid’
Which i think it belives that humanoid doesnt exist but i can ensure you that it does.
local plr2 = plr.Character.Humanoid
plr2.Health = 0
That variable is a table. If you wanna kill a specific player, do local player = game.Players:FindFirstChild("player name") then set their health to 0.
Hey! it works! thanks. Sorry I couldnt respond earlier. Could you explain the whole for i, v in pairs works? I see it everywhere yet dont know what id does…
It loops through everything inside of game:GetService("Players"):GetPlayers(), i is just the variable for how many times it loops, as in how many players there are in the server, and the v is the instance that it looped to, basically just the player in this scenario. For example you could do:
for playerCount, player in ipairs(game:GetService("Players"):GetPlayers()) do
player.Character:FindFirstChild("Humanoid").Health = 0
end
or if you’re looping through a model and all of it’s children you could do:
for partNumber, part in pairs(game.Workspace.Folder:GetChildren()) do
print(part.Name)
print(partNumber)
end