GetPlayers not running?

I’m really confused as to why Hello1 isn’t printing at all. When the start Bool Value is set to true, module:speed(16) works and which is a function in a module script that gets players in a in pairs loop and speeds the players that are in a tribe 16. But the in pairs loop doesn’t work at all it’s not even printing Hello1 and I’m so confused.

script.Parent.start.Changed:Connect(function(x)
	if x == true then
		script.Parent.start.Value = false
		for i, p in pairs(game.Players:GetPlayers()) do
			print("Hello1")
			if module:isintribe(p) == true then
				print("Hello2")
				module:disabletoolui(p)
			end
		end
		module:speed(16)
	end
end)
1 Like

delete the pairs, just put , in game.Players:GetPlayers()

There probably aren’t any players in the game when this is being ran

That doesn’t work. Just an in loop doesn’t exist.

There needs to be players in the game for a server to exist.

Not necessarily, if you’re just running the game instead of playing the game, there are no players, if i were you print game.Players:GetPlayers() before you do the for loop just to see what it prints to begin with!

Well that’s not the case in my situation since I’ve play tested with 3 players and all players have loaded. It’s a challenge where when the start value is set to true, the players have their toolbar disabled and their speed. The thing that’s weird is that the module:speed(16) is also a GetPlayers() which actually works but the previous one doesn’t.

for i, p in obj was added a while back, you don’t need pairs or ipairs, iteration is supported.

1 Like

I don’t think that’s a thing in Roblox Studio, but either way I tried it and it still doesn’t work.

image

i think your problem is with the script running before the players are loading in (?)
could be a studio timing issue too, often scripts run earlier/later than they would in a real game

That would be true if module:speed(16) was yielded i’m pretty sure. it just skips over the code block for some reason. also the players are 100% loaded in when the script is running

sorry i can’t help much further, i don’t know when the changed event is triggered :‎(

1 Like

Hello, first of all, above the whole for loop, print game.Player:GetPlayers() to see if it isn’t an empty table. Secondly, are you really sure module:speed(16) is the one running? Is not any other script running the same function? To check that, add another print where you call that function. Instead of using print, use breakpoints which are simpeler to use.

1 Like

Try printing game.Players:GetPlayers() before the loop. Is it empty for some reason? Are you trying this in run mode?

1 Like

ok its fixed the solution was rather embarrassing i forgot to set the walk speed to 0 when teleporting players and forgot to set the start value to start so it made it look like the module:speed(16) worked but in reality nothing did-