Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 29 Mar 2017 08:12 PM |
repeat wait() until game.Players.NumPlayers == 1 if game.Players.NumPlayers == 1 then round:Disconnect() mode.Value = "Waiting for Players" time.Value = 1 for _, player in ipairs(game.Players:GetChildren()) do local spawns = game.Workspace.Spawns:GetChildren() player.Character.HumanoidRootPart.CFrame = spawns[math.random(#spawns)].CFrame+Vector3.new(0,5,0) map:Destroy() end end
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
| |
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 29 Mar 2017 08:34 PM |
| Show script with the event |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 29 Mar 2017 08:39 PM |
I don't want to show the full event but its
local round = function() -- then it changes a bunch of string values, teleports players, choses a map, spawns it
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:39 PM |
So it's not an event then...?
|
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 29 Mar 2017 08:40 PM |
full code*
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 29 Mar 2017 08:40 PM |
Try this
local round round = function()
Then obvs youd do round:connect/round:disconnect() |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 29 Mar 2017 08:41 PM |
There is no remoteevent connected to this btw
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 29 Mar 2017 08:41 PM |
It doesnt work if it aint an event
|
|
|
| Report Abuse |
|
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 29 Mar 2017 08:42 PM |
I meant event as in .Touched .Chatted etc
|
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 29 Mar 2017 08:42 PM |
do you count while true do to be an event? lol
It's a function, and it loops through intermission, map selecting, being on the map, then ending and going back to intermission.
If there is only one player, then I want that to stop, but resume at intermission when it reaches 2 players again
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:43 PM |
"local round = function()"
Also, don't do that. It's bad practice, because if you need to call a function inside itself, it won't be defined at the time that the code is compiled, resulting in an error.
Either use:
local round round = function() end
Or:
local function round() end
They're both exactly the same thing; the first example I posted is what they both ultimately expand to though.
|
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 29 Mar 2017 08:45 PM |
Okay, I changed it to that, sub.
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:47 PM |
For my suggestion about the actual thing wrong with your code, I'd suggest connecting a function to the PlayerRemoving event and if NumPlayers is less than 2 then stop the round.
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:47 PM |
(and of course disconnect the function from the event when the round ends)
|
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 29 Mar 2017 08:50 PM |
Like this? game.Players.PlayerRemoving:connect(function(plr) if game.Players.NumPlayers == 1 then round:Disconnect() end end)
local round round = game.Players.PlayerAdded:connect(function()
--- loop and stuff
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:52 PM |
Something like:
local players = game:GetService("Players") local connection
local function stopRound() -- stop the round end
local connection = players.PlayerRemoving:Connect(function() if players.NumPlayers <= 1 then -- call the stop round function (filtered) connection:Disconnect() end end)
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:56 PM |
Remove the second `local` before the `connection` variable.
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 29 Mar 2017 08:57 PM |
if its a while loop you mean to use break
|
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 30 Mar 2017 08:50 AM |
How would I break the loop if I only want to do it when there is one player.
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Atavis
|
  |
| Joined: 10 Apr 2012 |
| Total Posts: 1463 |
|
|
| 30 Mar 2017 08:50 AM |
break;
idk this post is tl;dr
120,310 slices of pizza and counting! |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2017 10:47 AM |
You could check how many players there are every time the loop runs. Or else you could just set a boolean for the loop to check, using your event script.
while true do if bool == true then break end end
|
|
|
| Report Abuse |
|
|