How do i make a list of all players in a game? and Check their Health?

Thank you for the information, didn’t actually know that. But in this system it’s better to just wait for the character’s humanoid to load, waiting for the accessories is not nessacery it’s just gonna waste more time

1 Like
local Players = game.Players:GetChildren()

for i, v in pairs(Players) do
	print(i)---player priority
	print(v)---players name
	if v.LocalPlayer.Character.Humanoid.Health < 1 then
		print("Current Player Health Is"..v.LocalPlayer.Character.Humanoid.Health)
	end
end

This script may work…

The player is already there, no need to do v.LocalPlayer. And this is just the same problem with waiting for the character to load

Thanks for the suggestion, but i believe local player needs to be a local script

so far I got the game to tell me the player order, name, and health thank you u guys. Now
I’m trying to see if I can check when the player dies.

for i, v in pairs(game.Players:GetPlayers()) do
	for _, Player in pairs(game.Players:GetPlayers()) do
		print(i)
   		print(Player.Name) -- Player instance's name 	
    	local character = v.Character or v.CharacterAdded:Wait()
    	print(character.Humanoid.Health)
		if character.Humanoid.Health == 0 then
			print(character.Humanoid.Health)
		end
	end
end
2 Likes

Your final line makes no sense, why would you print the Health of a character which you’ve just affirmed is at zero health.

1 Like

just so I can check if the script is working, but its not liking the “== 0” thing

You know your script could get stuck on a single player if the v.Character instance never exists and they then leave. Hence why checking if the character exists is probably a better method.

1 Like

how would you check if the character exists? would you do something like

if v.Character then
 ---stuff
end
1 Like
if v.Character [Insert Code here] then
    [Code Here]
elseif v.Character == nil then
    return
end

so are you saying when a player dies the “Character” gets removed?

1 Like

If an player exceeds the FallenPartsDestroyHeight/Void,then yes.

what about if another player kills them or they reset?

Now i noticed,they will die,they will wait the RespawnTime,and their body will be copied and pasted into the spawners.