GetPlayers() isnt working

Hello! My goal is pretty straightforward, id like for the table to print to the server when there is 1 player in each team but to some unknown reason it isnt working!

If you could help me that would be nice! my scripting skills arent that great.

Its inside a function if anyone is wondering.

	while true do
		local Htable = Hteam:GetPlayers()
		local Stable = Steam:GetPlayers()
		
		if #Htable == 1 and #Stable == 1 then
			print("Works")
		end
	end
end

edit: I was wrong, you can do :GetPlayers on a team, this may be a different error in the script.
https://create.roblox.com/docs/reference/engine/classes/Team#GetPlayers

this is big boy misinformation

100% im sure its this you need to do :GetChildren, because when in a team the player is in the folder Team 1

oh sorry im just not that good at scripting :laughing: , i said that because i actually thought that because ive heard someone say it and in my head i got that

There is not a task.wait() (or anything else like that) within your while true loop, do you think this may be the cause? You’re most likely getting the error: Script timeout: exhausted allowed execution time

while true do
	task.wait( 0.5 ) -- Now has a wait.
	local Htable = Hteam:GetPlayers()
	local Stable = Steam:GetPlayers()

	if #Htable == 1 and #Stable == 1 then
		print("Works")
	end
end

Thank you for that, I wasn’t aware :GetPlayers() actually had that functionality for Team instances.

Do you ever call the function? (and add a task.wait in your loop)

I don’t get an error but I will test this tomorrow! Thanks!!

I do call the function and I’ll test the task.wait tomorrow thanks!!

To add, I can recommend spamming print statements to make sure that’s where the issue is

Could be multiple things :person_shrugging:

Give the beginner a break

Thank you for this! I have always wondered what break points do I’ll make sure to read this!! thank you so much!!

I tend to place print statements just like u mentioned!

this looks like it should work, is there any more information?

Well, there is no way out of that loop.. I may not lockup, but it’s never going to stop looping either.

but it should still be printing “Works” regardless?

10,000+ times.. Why are we looking at snippets here?
This not Snippet Support.

Sorry :rofl: you asked; “this looks like it should work, is there any more information?”

It’s not my code and not my system. I offerred them the solution to their problem and no additional help is needed. I’m sure they’re capable of scripting their own break statement (if applicable), if not they can make another forum post lol.

The code should work. As long as you change the players’ teams on the server (with a Script) and there isn’t any code underneath the while loop in the same scope.