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: Missing Argument?

Previous Thread :: Next Thread 
RosieLily is not online. 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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
02 May 2014 03:55 AM
This is nil:
Workspace.Spawns:GetChildren().Position
Report Abuse
RosieLily is not online. 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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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 is not online. 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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
02 May 2014 04:20 AM
What do you mean by put a character there?
Report Abuse
RosieLily is not online. 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
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
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 is not online. 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 is not online. 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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
02 May 2014 01:10 PM
No problem :D
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