local Players=game:GetService"Players"
local prefix,cmds,findtarget,debounce,getmsg=":",nil,function(player,name)
name=name or "me"
local target;
if name=="me"then
target=player
else
for _,v in ipairs(Players:GetPlayers())do
if v.Name:lower():sub(1,name:len())==name then
target=v;break;
end
end
end
return target
end,{},function(tab)
local str=""
for i,v in ipairs(tab)do
str=str.." "..v
end
return str
end
local admins,onChatted={jaisonDXYX="Owner",Builderman="Admin",Noob="TempAdmin"},function(player,msg)
if msg:sub(1,1)==prefix and msg:len()>1 then
msg=msg:lower():sub(2,msg:len())
local tab=string.split(msg," ")
local cmd,arg1=tab[1],tab[2]
table.remove(tab,1)table.remove(tab,1)
cmd=cmds[cmd]
if not cmd then return end
local arg1s=arg1
arg1=findtarget(player,arg1)or arg1
cmd(player,type(arg1)~="string"and arg1 or nil,(arg1s or "")..getmsg(tab))
end
end
cmds={
ff=function(player,target)if not target then return end;Instance.new("ForceField",target.Character)end,
unff=function(player,target)
if not target then return end
local char=target.Character
local ff=char and char:FindFirstChildOfClass"ForceField"
if ff then ff:Destroy()end
end,
respawn=function(player,target)if not target then return end;target:LoadCharacter()end,
kick=function(player,target,msg)if target and target~=player then target:Kick(msg or "")end;end,
kill=function(player,target)
if not target then return end
local char=player.Character
local hum=char and char:FindFirstChildOfClass"Humanoid"
if hum and hum.Health>0 then hum.Health=0 end
end,
punish=function(player,target)
if not target then return end
local char=target.Character
if char then char.Parent=nil end;
end,
h=function(player,target,msg)
local m=Instance.new("Hint",workspace)
m.Text=msg
wait(2)
m:Destroy()
end,
m=function(player,target,msg)
local m=Instance.new("Message",workspace)
m.Text=msg
wait(2)
m:Destroy()
end,
admin=function(player,target,msg)
if not target or target==player then return end
admins[target.Name]="TempAdmin"
end,
pa=function(player,target,msg)
if admins[player.Name]=="Owner"and target and target~=player then
admins[target.Name]="Admin"end
end,
adminlist=function()for i,v in pairs(admins)do print(i,v)end;end;
}
local function onPlayerAdded(player)
if admins[player.Name]then
player.Chatted:Connect(function(msg)
if debounce[player.Name]then return end
debounce[player.Name]=true
pcall(onChatted,player,msg)
wait(1)
debounce[player.Name]=false
end)
end
end;Players.PlayerAdded:Connect(onPlayerAdded)
for _,v in ipairs(Players:GetPlayers())do
onPlayerAdded(v)
end
3 comments
The reason as to why or works is because you are giving a direct message afterwards, in this case "bruh". However, without it you are telling the program to use the array with no specified index. Try using Placeholder[msg] instead of msg == Placeholder
Placeholder is not a dictionary, RazzyPlayz.
Oh yeah, it's an array. My bad