|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
DEVMAC101
|
  |
| Joined: 01 May 2013 |
| Total Posts: 856 |
|
|
| 07 Jul 2014 08:32 AM |
| Haha sorry. I've got nothing, sorry. |
|
|
| Report Abuse |
|
|
DEVMAC101
|
  |
| Joined: 01 May 2013 |
| Total Posts: 856 |
|
|
| 07 Jul 2014 08:35 AM |
| Post more of the code for me? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 07 Jul 2014 08:39 AM |
| Why don't you explain the hierarchy?. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 07 Jul 2014 08:55 AM |
| Try adding a check to make sure the GUI is in existance. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 07 Jul 2014 09:38 AM |
Now it says in the output:
Waiting is not a valid member of ScreenGUI |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|