generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

How do I check and see if there is atleast 2 players

Previous Thread :: Next Thread 
Eventive is not online. Eventive
Joined: 28 Jul 2011
Total Posts: 9827
25 Feb 2017 09:31 PM
before firing a function?


ATR'er since 2013.
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
25 Feb 2017 09:33 PM
if game.Players.NumPlayers>= 2 then
--fire function
end
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
25 Feb 2017 09:33 PM
Check once?

if game:GetService("Players").NumPlayers < 2 then
return
end

Yield?

while game:GetService("Players").NumPlayers < 2 do
wait()
end


Report Abuse
Disaster_Scripts is not online. Disaster_Scripts
Joined: 10 May 2016
Total Posts: 2310
25 Feb 2017 09:34 PM
And if it is supposed to stop when there is only ### player... repeat wait() until ####################### < #
Report Abuse
Disaster_Scripts is not online. Disaster_Scripts
Joined: 10 May 2016
Total Posts: 2310
25 Feb 2017 09:35 PM
Ok tags
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
25 Feb 2017 09:42 PM
@unsub BAd

while game:GetService("Players").NumPlayers < 2 do
game:GetService('Players').PlayerAdded:Wait()
end


Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
25 Feb 2017 09:44 PM
There's nothing wrong with yielding using wait().
With your method you shouldn't be using a loop. Even then, it may need to run twice because it's possible for a server to exist with 0 players.

If you want to yield, you should use a loop like I demonstrated.


Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
25 Feb 2017 09:45 PM
Actually, I interpreted that wrong. I guess you can use that method if you want to save yourself <=1/30 seconds


Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
25 Feb 2017 10:27 PM
I don't get why numplayers is even a thing. just do

#game.Players:GetPlayers()


Ever wanted to learn how to script? Check out my YouTube channel: youtube.com/austintheslayer Want to see me code in action? Follow me on twitch: twitch.tv/austinrblx
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image