RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 03:43 AM |
I'm trying to bring the winners back to the lobby, but getting a missing argument error on line 5. Please help me.
game.ServerStorage.RoundComplete.Event:connect(function(WinningPlayers,PointsIssued) local WinnersMsg = "Congratulations!" for i = 1, #WinningPlayers do WinningPlayers[i].leaderstats.Points.Value = WinningPlayers [i].leaderstats.Points.Value + PointsIssued if #WinningPlayers > 0 then WinningPlayers[i].Character:MoveTo(Workspace.Spawns:GetChildren().Position) end end |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 03:55 AM |
This is nil: Workspace.Spawns:GetChildren().Position
|
|
|
| Report Abuse |
|
|
RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 04:12 AM |
I changed it to WinningPlayers[i].Character:MoveTo(Workspace.Spawns.SpawnLocation.Position) which isn't what I wanted because wanted players to randomly spawn to any of the 5 spawns, but it should work at least.
Still getting an error on the same line attempt to index field 'Character' (a nil value) WinningPlayers[i] is Player so i'm unsure why I get the error. |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:15 AM |
You can do this:
local Spawns=Workspace.Spawns:GetChildren() WinningPlayers[i].Character:MoveTo(Spawns[math.random(#Spawns)].Position)
Also make sure the Character is there, Player.Character can be nil. |
|
|
| Report Abuse |
|
|
RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 04:19 AM |
| Okay, thank you. How could I put character there without effecting the characters already in the lobby? |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:20 AM |
| What do you mean by put a character there? |
|
|
| Report Abuse |
|
|
RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 04:25 AM |
Well I think that WinningPlayers is actually data and not referring to the actual player, i'm not sure how to test it. The only way I can think to make it work is by making a Players = game.Players:GetPlayers() but I don't want to move all of them.. only the ones who won. Sorry i'm new at scripting.. |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:30 AM |
| either have a table of winners or add a bool value to the players that indicates their win status |
|
|
| Report Abuse |
|
|
RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 04:31 AM |
| I will just kill the players after each game. It's bad for wipeouts but it's something I know how to do. Ty for all your help! |
|
|
| Report Abuse |
|
|
RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 04:32 AM |
| I honestly would have never thought of that! Thank you!! [SOLVED] |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:33 AM |
Because of the way you're accessing the leaderstats, it seems like it should be referring to the actual player object. Instead of this: if #WinningPlayers > 0 then
try this: if WinningPlayers[i].Character then |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:35 AM |
"I'm trying to bring the winners back to the lobby, but getting a missing argument error on line 5. Please help me."
None of you even checked line 5...
1. game.ServerStorage.RoundComplete.Event:connect(function(WinningPlayers,PointsIssued) 2. local WinnersMsg = "Congratulations!" 3. for i = 1, #WinningPlayers do 4. WinningPlayers[i].leaderstats.Points.Value = WinningPlayers 5. [i].leaderstats.Points.Value + PointsIssued 6. if #WinningPlayers > 0 then 7. WinningPlayers[i].Character:MoveTo(Workspace.Spawns:GetChildren().Position) 8. end 9. end
[i].leaderstats.Points.Value + PointsIssued
Should be
WinningPlayers[i].leaderstats.Points.Value = WinningPlayers[i].leaderstats.Points.Value + PointsIssued
Also to tele to a random spawn here's the line you need for line 7;
WinningPlayers[i].Character:MoveTo(Workspace.Spawns:GetChildren()[math.random(1,#Workspace.Spawns:GetChildren())].Position)
Hope I helped :D |
|
|
| Report Abuse |
|
|
RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 04:37 AM |
| That's much easier than adding a bool value! Thanks for all the help monkeyman. ((: |
|
|
| Report Abuse |
|
|
RosieLily
|
  |
| Joined: 25 Feb 2014 |
| Total Posts: 129 |
|
|
| 02 May 2014 04:40 AM |
| @warspyking - it is actually line 5, but the forums brought the longer lines to new lines. ty for the spawn tip though. |
|
|
| Report Abuse |
|
|
| |
|