Hey folks, today I was attempting to make my admin command script(with the help of the wiki).
While I don't see anything wrong with the script, it doesn't work.
--Original script made by Thetacah --Ban script --Last Modified:2016/08/28 local admins = {[37040233] = true} local bannedlist = {} function findplayer(name) for i, v in ipairs(game.Players:GetPlayers()) do if(v and v.Character) then if v.Name:lower() == name:lower() then return v end end end end function chatted(msg, plr) --We are admin if(admins(plr.userId)) then if(string.lower(msg:sub(1,5)) == "kill/") then local killVictim = findplayer(msg:sub(6)) if(killVictim and killVictim.Character) then killVictim.Character:BreakJoints() end end if(string.lower(msg:sub(1,5)) == "kick/") then local kickVictim = findplayer(msg:sub(6)) if(kickVictim and kickVictim.Character) then kickVictim:Kick() end end if(string.lower(msg:sub(1,4)) == "sit/") then local sitvicitim = findplayer(msg:sub(5)) if(sitvicitim and sitvicitim.Character) then sitvicitim.Character:FindFirstChild("Humanoid").Sit = true end end end end --When player chats, run this game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) chatted(msg,plr) end) for i, v in pairs(bannedlist) do if(v) then if(plr.userId == v) then plr:Kick() end end end end)
I've added comments on two lines. You had problems.
--Original script made by Thetacah --Ban script --Last Modified:2016/08/28 local admins = {[37040233] = true} local bannedlist = {} function findplayer(name) for i, v in ipairs(game.Players:GetPlayers()) do if(v and v.Character) then if v.Name:lower() == name:lower() then return v end end end end function chatted(msg, plr) --We are admin if(admins(plr.userId)) then --\\admins(plr.userId) should be admins[plr.UserId]. userId is deprecated in favor of UserId I'm pretty sure, although both work. And you don't call admins like a functions, you index the player's UserId in it. admins is a table not a function. if(string.lower(msg:sub(1,5)) == "kill/") then local killVictim = findplayer(msg:sub(6)) if(killVictim and killVictim.Character) then killVictim.Character:BreakJoints() end end if(string.lower(msg:sub(1,5)) == "kick/") then local kickVictim = findplayer(msg:sub(6)) if(kickVictim and kickVictim.Character) then kickVictim:Kick() end end if(string.lower(msg:sub(1,4)) == "sit/") then local sitvicitim = findplayer(msg:sub(5)) if(sitvicitim and sitvicitim.Character) then sitvicitim.Character:FindFirstChild("Humanoid").Sit = true end end end end --When player chats, run this game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) chatted(msg,plr) end) for i, v in pairs(bannedlist) do if(v) then --\\This check is useless, v will always exist. if(plr.userId == v) then --\\Same thing with UserId as above, userId is deprecated I'm pretty sure. Other than that it looks okay. plr:Kick() end end end end)