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 » Scripting Helpers
Home Search
 

Re: Not Enough Players

Previous Thread :: Next Thread 
Cizox is not online. Cizox
Joined: 25 Dec 2009
Total Posts: 42220
21 Nov 2013 06:11 PM
messageOne = "Need at least two players to begin."
messageTwo = "Enough players to begin. Loading game."

message = Instance.new("Message")
message.Parent = nil

players = game.Players.NumPlayers

while true do
wait()
if (players <= 1) then
message.Parent = game.Workspace
message.Text = messageOne
elseif (players > 1) then
message.Parent = game.Workspace
message.Text = messageTwo
wait(2)
message.Parent = nil
end
end

Tried it using Start Server and Start Player. The first message appears, but when there are more than 1 players, the message doesn't change. any help?
Report Abuse
Jetta765214 is not online. Jetta765214
Joined: 22 Oct 2008
Total Posts: 1855
21 Nov 2013 06:14 PM
messageOne = "Need at least two players to begin."
messageTwo = "Enough players to begin. Loading game."

message = Instance.new("Message")
message.Parent = nil


while true do
wait()
players = game.Players.NumPlayers
if (players <= 1) then
message.Parent = game.Workspace
message.Text = messageOne
elseif (players > 1) then
message.Parent = game.Workspace
message.Text = messageTwo
wait(2)
message.Parent = nil
end
end
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
21 Nov 2013 06:16 PM
Because you initialize the variable players once. So, it's only storing one value.

local messageOne, messageTwo = 'Need at least two players to begin.', 'Enough players to begin. Loading game.'
local message = Instance.new('Message', Workspace) -- no point in putting it in nil, if you're using a while loop it will always just parent itself to workspace

while (wait()) do
local gar = players <= 1
message.Text = gar and messageOne or messageTwo
message.Parent = gar and Workspace or nil
end
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
21 Nov 2013 06:16 PM
*sigh*

local messageOne, messageTwo = 'Need at least two players to begin.', 'Enough players to begin. Loading game.'
local message = Instance.new('Message', Workspace) -- no point in putting it in nil, if you're using a while loop it will always just parent itself to workspace

while (wait()) do
local gar = Game.Players.NumPlayers <= 1
message.Text = gar and messageOne or messageTwo
message.Parent = gar and Workspace or nil
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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