|
| 05 Jan 2014 05:49 PM |
I'm getting this error:
attempt to call field "Effect" (a nil value)
What did I do wrong with my admin commands? Here is the line that errors:
command.Effect(player,msg)
and here is the script:
admins = {evolvedpikachu = 10}
banned = {"urmom"} -- For all the banned players
commands = { { Effect = function(player,msg) Instance.new("Message",Workspace).Text = player.Name.." has said "..msg end; Rank = 1; Words = {"test"} } }
function IsValid(player,list,isdictionary,rank) if isdictionary then -- If it is a dictionary if list[player.Name] and not rank then -- if I am not checking for rank, just if it's there return true elseif list[player.Name] and rank then -- if I am checking for rank AND if it's there if tonumber(list[player.Name]) then if list[player.Name] >= rank then return true end end end elseif not isdictionary then -- If it is not a dictionary for i, v in pairs(list) do if player.Name == v then return true end end end return false end
game.Players.PlayerAdded:connect(function(player)
if IsValid(player,banned) then -- Is the player in the banned list? player:Kick() end
if IsValid(player,admins,true) then -- If you are in the admins table then you will be connected to the Chatted event player.Chatted:connect(function(msg) for i, command in pairs(commands) do for i, v in pairs(command.Words) do if msg:match(v) and IsValid(player,admins,true,command.Rank) then command.Effect(player,msg) end end end end) end end) |
|
|
| Report Abuse |
|
|
|
| 05 Jan 2014 08:33 PM |
| Bet you thought I was a Kohl's Admin scrub. |
|
|
| Report Abuse |
|
|
VilleSlay
|
  |
| Joined: 14 May 2011 |
| Total Posts: 1405 |
|
|
| 05 Jan 2014 08:37 PM |
>Trying to get a function from a table named command when the table is named commands. > Trying to get it as if it was a Java class.
~~> Ville <~~ |
|
|
| Report Abuse |
|
|
|
| 05 Jan 2014 08:38 PM |
@Ville
LOL I JUST NOTICED THAT
Also idk Java so idk what you mean by that. |
|
|
| Report Abuse |
|
|
|
| 05 Jan 2014 08:42 PM |
@Ville
Actually, that was on purpose. Look closely, command is something in the commands table.
for i, command in pairs(commands) do for i, v in pairs(command.Words) do if msg:match(v) and IsValid(player,admins,true,command.Rank) then command.Effect(player,msg) end end end |
|
|
| Report Abuse |
|
|
VilleSlay
|
  |
| Joined: 14 May 2011 |
| Total Posts: 1405 |
|
|
| 05 Jan 2014 08:47 PM |
Looping, you're not doing it right.
~~> Ville <~~ |
|
|
| Report Abuse |
|
|
|
| 05 Jan 2014 08:49 PM |
| Huh, I somehow got it to work. Even though I did literally nothing but a bunch of test theories. kthxbai |
|
|
| Report Abuse |
|
|