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 |
|
|
| 30 Jul 2015 10:15 AM |
| Your GetTargets functions needs to return the Targets table. |
|
|
| Report Abuse |
|
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 |
|
|
| 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 |
|