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: How would I do this?

Previous Thread :: Next Thread 
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 08:01 AM
Im making a game that needs at least 4 people to play, so I'm trying to make a script that makes it so if there are less than 4 players, you stay in the waiting box, but if there are 4 or more players, a round starts. All the way's I've tried have not worked.
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
07 Jul 2014 08:02 AM
if game.Players.NumPlayers >4 then
print ("GAME PLAYER COUNT IS READY")
wait(5)
game.Workspace.GamePhase.Value = 1
else
print ("GAME PLAYER COUNT ISN'T READ")
wait(5)
end
end

Just add a loop to make sure it checks to see if the game has 4 players.
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 08:03 AM
while wait() do
if game.Players.NumPlayers == 4 then
--Code Here
else
--More Code Here
end
end
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
07 Jul 2014 08:03 AM
Ooops take away the gamephase.value thing that is an old code from my old game.
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
07 Jul 2014 08:04 AM
if game.Players.NumPlayers >4 then
print ("GAME PLAYER COUNT IS READY")
else
print ("GAME PLAYER COUNT ISN'T READ")
wait(5)
end
end
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 08:08 AM
That works, but what's happening when I test with 4 players, I think what it's doing is, detecting that there are less than 4 players while they are all still joining, then it is just displaying the waiting for players message because the script hit an end?
How do I make it so that, once the fourth player joins, it is ready to start the match?
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
07 Jul 2014 08:10 AM
if game.Players.NumPlayers =>4 then
print ("GAME PLAYER COUNT IS READY")
else
print ("GAME PLAYER COUNT ISN'T READ")
wait(5)
end
end

This is the starter, you got to finish the rest. After print("GAME PLAYER COUNT IS READY" is where you type your code to make stuff happen.
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 08:15 AM
Ok, so I discovered that my script is stack ending:

for k,p in pairs(game.Players:GetPlayers()) do
p.PlayerGui.Announcements.Waiting.Visible = true --This Line
end

The output says, Announcements is not a valid member of PlayerGui
But, that doesn't make sense, because It is obviously there, and it is referenced many times during the script, and it worked all of the other times.
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 08:28 AM
@DEVMAC

You still there?
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
07 Jul 2014 08:32 AM
Haha sorry. I've got nothing, sorry.
Report Abuse
DEVMAC101 is not online. DEVMAC101
Joined: 01 May 2013
Total Posts: 856
07 Jul 2014 08:35 AM
Post more of the code for me?
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 08:36 AM
while wait() do
for k,p in pairs(game.Players:GetPlayers()) do
if p.PlayerGui:FindFirstChild("Announcements") then
p.PlayerGui.Announcements.Waiting.Visible = true --This Line
end
end
end
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 08:37 AM
So, this is the entire code after the else:

else
wait(4)
print("PLAYER COUNT ISNT READY")
for k,p in pairs(game.Players:GetPlayers()) do
p.PlayerGui.Announcements.Waiting.Visible = true
end
end
end

The Waiting GUI is just a little thing that says it's waiting for 4 players.
The path of the GUI is game.StarterGui.Announcements.Waiting

I have no Idea why it's saying it is not valid...
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 08:39 AM
Why don't you explain the hierarchy?.
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 08:48 AM
I really don't understand what is happening. The GUI is clearly there, I don't know why the script can't find it.
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 08:55 AM
Try adding a check to make sure the GUI is in existance.
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 09:00 AM
I just did the code you gave me where it checks for the gui.
It is still stack ending.
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 09:06 AM
Any more errors?.
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 09:12 AM
while wait() do
for k,p in pairs(game.Players:GetChildren()) do
if game.Players.NumPlayers >=4 then
print ("GAME PLAYER COUNT IS READY")
else
print ("GAME PLAYER COUNT ISN'T READY")
end
if p.PlayerGui.Announcements ~= nil then
p.PlayerGui.Announcements.Waiting.Visible = true
end
end
end
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 09:38 AM
Now it says in the output:

Waiting is not a valid member of ScreenGUI
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
07 Jul 2014 10:07 AM
Put a local script into starter gui and put this script in it.

local sp = script.Parent
local plr = Game.Players.LocalPlayer

repeat wait(.1)until Game.Players.NumPlayers == 4
if Game.Players.NumPlayers == 4 then
plr.PlayerGui.Announcements.Waiting.Visible = false
plr.Postion = workspace.TPBrick.Position+Vector3.new(0,.5,0)
else
plr.PlayerGui.Announcements.Waiting.Visible = true
end
Report Abuse
oscar9999991 is not online. oscar9999991
Joined: 15 Nov 2009
Total Posts: 11373
07 Jul 2014 10:18 AM
the script includes the teleport to the round... name the part that you want to teleport to TPBrick
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 11:26 AM
I don't need to include the teleport to the round, because that is all already made in my script, putting in another one would be pointless and probably just break it.
Report Abuse
jonathan48 is not online. jonathan48
Joined: 30 Apr 2008
Total Posts: 1227
07 Jul 2014 11:58 AM
Bump
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 12:01 PM
while wait() do
for k,p in pairs(game.Players:GetChildren()) do
if game.Players.NumPlayers >=4 then
print ("GAME PLAYER COUNT IS READY")
else
print ("GAME PLAYER COUNT ISN'T READY")
end
if p.PlayerGui.Announcements ~= nil and p.PlayerGui.Announcements:FindFirstChild("Waiting") then
p.PlayerGui.Announcements.Waiting.Visible = true
end
end
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