So I'm making a script to detect if 1 player is in the game, and it uses if statement.
p = game:GetService("Players"):GetChildren() if p == 1 then print ("One player.") end
And it is not working, and it is in a script, not a local one, and I puted it in the Game.Players Pls tell me whats wrong if you can.
p = game:GetService("Players"):GetChildren() if #p == 1 then print ("One player.") end
You're welcome :) To get the length of the table (amount of players) you need to use # in front of it.
Hey Smach28,
wait(2); local player_service = game:GetService("Players") local players = player_service:GetPlayers(); print(#players .. " is the amount of players.");
wait(2); local players = game:GetService("Players"); local amount = players.NumPlayers; print(amount .. " is the amount of players.");
~~ KingLoneCat
Try this:
wait(1) local p = game.Players:GetChildren() print(#p.." Player(s)")
By adding the wait time, it waits for all the players to fully load in, and then it searches for all players, and lets you know how many players there are.