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 » Scripters
Home Search
 

Re: bad argument #1 to 'pairs' (table expected, got nil)

Previous Thread :: Next Thread 
2JJ1 is not online. 2JJ1
Joined: 15 Mar 2012
Total Posts: 1571
30 Jul 2015 10:10 AM
Admins = {}
GroupId = 00000 --Leave as non existent groupid to keep disabled
GroupRank = 90 --Rank in group to receive admin
InitialCom = ";" --What must be said in order for the command to execute

game.Players.PlayerAdded:connect(function(plr)
Admins[#Admins + 1] = plr --Temp gives everyone admin
if plr:GetRankInGroup(GroupId) == GroupRank then
Admins[#Admins + 1] = plr
end
for i,v in next, Admins do
if Admins[i] == plr then
plr.Chatted:connect(function(chatContent)
commands(chatContent,plr)
end)
end
end
end)

function GetTargets(plr,chatContent)
local Targets = {} chatContent:lower()
if chatContent == "me" then
table.insert(Targets,plr.Name)
end
end

function commands(chatContent,plr)
if string.sub(chatContent,1,5) == "kill " then
local Targets = GetTargets(plr,chatContent:lower():sub(6))
for i, v in pairs (Targets) do
coroutine.resume(coroutine.create(function()
if v and v.Character then
v.Character:BreakJoints()
end
end))
end
end
end


If I could just get this to work... I could finally make efficient admin commands.
This is the entire script, so you can go into studio and see whats happening easily.

In commands(), I keep getting an error in for i,v in pairs.
ServerScriptService.2JJ1's Admin:31: bad argument #1 to 'pairs' (table expected, got nil)

Halp me fix this PLSSS!!
Report Abuse
QuintinityZero is not online. QuintinityZero
Joined: 01 Oct 2008
Total Posts: 10618
30 Jul 2015 10:15 AM
Your GetTargets functions needs to return the Targets table.
Report Abuse
2JJ1 is not online. 2JJ1
Joined: 15 Mar 2012
Total Posts: 1571
30 Jul 2015 10:20 AM
Think you can put it into the script? I never really have knew how to use return.
I'll hopefully figure out if I see it.
Report Abuse
QuintinityZero is not online. QuintinityZero
Joined: 01 Oct 2008
Total Posts: 10618
30 Jul 2015 10:22 AM
function GetTargets(plr,chatContent)
local Targets = {}
chatContent:lower()
if chatContent == "me" then
table.insert(Targets,plr.Name)
end
return Targets -- you need to return the table, otherwise this function is useless
end

Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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