I've been stuck on this for about 20 minutes and for some reason it doesn't run the same amount of times as there are players.
for i = 1, #game:GetService("Players"):GetPlayers() do local Sam = SERVERQBA:Clone() Sam.Name = i Sam.Parent = SERVERQBAT Sam.LayoutOrder = i SERVERQBAT.CanvasSize = UDim2.new(0, 0, 0, 50 * i) end
game.Players.PlayerAdded:Connect(function() local plrs = game.Players:GetPlayers() for i = 1, #plrs do -- Rest of the code here end end)
for loop will never fail to detect at least 1 player if used in this manner.
I've had this problem multiple times before, and I found out that the script was running before a player was even added. The solution I did for this was I added it in a PlayerAdded event, but it makes it run every time a new player joins.
Probably use a repeating loop until the number of
Players:GetPlayers() is more than 1