If I loop through all instances in the Players service, will every instance be a Player?

Very basic and simple question, if I loop through every instance inside the Players service, will every instance be a Player, or will I have to check if the instance is a Player?

For example, I have some code that checks what team every player is on, and then teleports them to the lobby. I haven’t code much, not much at all, but I want to make sure I’m doing this right.

Current Code:

	for i, plr: Player? in pairs(Players:GetChildren()) do
		if plr:IsA("Player") then --// Should I do this??
			--// Code here
		end
	end

If each instance inside of Players was a Player, the code would look like this:

	for i, plr: Player in pairs(Players:GetChildren()) do
		--// Code here
	end

Thanks.

You could do

game.Players:GetPlayers()
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.