Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 02:26 PM |
function startRound() startedGame = true for i,v in pairs(game.Players:GetPlayers()) do v.TeamColor = game.Teams.Alive.TeamColor v.Character:MoveTo(workspace.AliveSpawn.Position) end end
game.Players.PlayerAdded:connect(function(p) if game.Players.NumPlayers >= 2 and not startedGame then StartEvent:FireAllClients() startRound() else print("Waiting") end end)
Basically, if 2 players join, 1 gets on the team. If 3 players join, 1 player gets on the team, etc. If that makes sense, sorry.
Thanks, appreciate it! |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
| |
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
| |
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
| |
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
| |
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
| |
|
Era_Gamer
|
  |
| Joined: 24 Feb 2016 |
| Total Posts: 549 |
|
|
| 07 Aug 2016 09:28 PM |
Any errors? How are we expected to help with only the tip of "NumPlayers issue". More information please.
#code game.Players.Era_Gamer:Kick() |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 09:31 PM |
| That's why I am confused, no errors. |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 09:32 PM |
| It is just working improperly, and I cannot figure out how to fix it. |
|
|
| Report Abuse |
|
|
Era_Gamer
|
  |
| Joined: 24 Feb 2016 |
| Total Posts: 549 |
|
|
| 07 Aug 2016 09:33 PM |
Is it teaming everyone to the same team?
#code game.Players.Era_Gamer:Kick() |
|
|
| Report Abuse |
|
|
Era_Gamer
|
  |
| Joined: 24 Feb 2016 |
| Total Posts: 549 |
|
|
| 07 Aug 2016 09:34 PM |
Or are you saying no matter the amount of players, only one gets teamed.
#code game.Players.Era_Gamer:Kick() |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 09:34 PM |
"Basically, if 2 players join, 1 gets on the team. If 3 players join, 1 player gets on the team, etc. If that makes sense, sorry."
One player joins the team, that's it. |
|
|
| Report Abuse |
|
|
Era_Gamer
|
  |
| Joined: 24 Feb 2016 |
| Total Posts: 549 |
|
|
| 07 Aug 2016 09:39 PM |
A little wordy, which was why I wasn't sure.
As far as some previous issues I had with pairs that were odd, I don't like to use it for player count, especially when the count can change. So what I suggest doing is making a table inside of the startRound function.
local plrs = game.Players:GetPlayers()
for i = 1,#plrs do plrs[i].TeamColor = game.Teams.Alive.TeamColor plrs[i].Character:MoveTo(workspace.AliveSpawn.Position) end
Along with whatever else. Hopefully this fixes your issue. If not, come back again, hopefully with an error.
#code game.Players.Era_Gamer:Kick() |
|
|
| Report Abuse |
|
|
Era_Gamer
|
  |
| Joined: 24 Feb 2016 |
| Total Posts: 549 |
|
|
| 07 Aug 2016 09:40 PM |
Wait one second, let me post the script with tables instead
#code game.Players.Era_Gamer:Kick() |
|
|
| Report Abuse |
|
|
Era_Gamer
|
  |
| Joined: 24 Feb 2016 |
| Total Posts: 549 |
|
|
| 07 Aug 2016 09:43 PM |
Nevermind that ^ Instead let me say:
Basically I prefer not to use pairs when the number of something can change, rather a table. I only use it when I must.
#code game.Players.Era_Gamer:Kick() |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 09:43 PM |
| Yeah, I'll see, I gotcha, thanks. |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 09:47 PM |
If I do something like this;
function startRound() startedGame = true for i = 1,#Players do Players[i].TeamColor = game.Teams.Alive.TeamColor end end
game.Players.PlayerAdded:connect(function(p) if game.Players.NumPlayers >= 1 then StartEvent:FireAllClients() startRound() else print("Waiting") end end)
It doesn't put any player on any teams. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 07 Aug 2016 09:51 PM |
| I'd totally help you; however, the way you worded it makes it so I can't you need to get straight to the point and not be vague. |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 09:52 PM |
Sorry.
It places ONE player on the the 'Alive' team, and the rest stay on the Lobby team. When it should be placing EACH user on the Alive team. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 07 Aug 2016 09:58 PM |
| Ok, so why are you using playeradded, it'll run the code each time a person joins and it won't start a new round until someone joins... |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 10:00 PM |
| Someone told me try that lmao. |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 10:04 PM |
Now if I do something like this:
function startRound() startedGame = true for i = 1,#Players do Players[i].TeamColor = game.Teams.Alive.TeamColor end end
function startedEngine() if game.Players.NumPlayers >= 2 then startRound() print("Starting") else print("Waiting") end end
startedEngine()
It always prints wait, no matter the number of players in the game. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 07 Aug 2016 10:07 PM |
--Exmaple and 100% untested. :P --Still so much you can add to this too.
function StartRound() print'Waiting on two or more players.' repeat wait() until #game.Players:GetChildren() > 1 StartEvent:FireAllClients() for i,v in pairs(game.Players:GetChildren()) do v.TeamColor = game.Teams.Alive.TeamColor spawn(function() repeat wait() until v.Character and v.Character:FindFirstChild'HumanoidRootPart' local t = v.Character:FindFirstChild'HumanoidRootPart' t.CFrame = workspace.AliveSpawn.CFrame + Vector3.new(math.random(-3,3),3,math.random(-3,3)) end) end --Round ended so start a new one. :P print'New round in 15...' wait(15) StartRound() end StartRound() |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 10:13 PM |
Thanks, appreciate it, but it's still not working.
I did this for example;
function setupGame() repeat wait () until #(game.Players:GetChildren()) >= 1 StartEvent:FireAllClients() for i,v in pairs(game.Players:GetPlayers()) do v.TeamColor = game.Teams.Alive.TeamColor v.Character:MoveTo(workspace.AliveSpawn.Position) end end
setupGame()
(keep in mind it works with two players I believe, just not above that)
Here was the result: prntscr /c2wwpc |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 07 Aug 2016 10:14 PM |
| wait, I missed something that you said, let me see, sry. |
|
|
| Report Abuse |
|
|