local admin = game:GetService("ReplicatedStorage"):WaitForChild("AdminEvent") local adminPanel = game.ServerStorage.ServerData.Other.AdminGui local cmdlist = {"kick","god","kill"} game.Players.PlayerAdded:Connect(function(plr) -- Add admin UI if plr:GetRankInGroup(3957601) >= 252 then local addpanel = adminPanel:Clone() repeat wait() until plr:HasAppearanceLoaded() addpanel.Parent = plr.PlayerGui end end) admin.OnServerEvent:Connect(function(plr, cmd, par1, par2) -- On command event run if plr:GetRankInGroup(3957601) >= 252 then local function check() -- check if cmd is an actual command for i,v in pairs(cmdlist) do if v == cmd then return true -- if yes, return true else return nil -- if not, return nothing end end end if check() then -- if check() returns true, check for parameters if par1 ~= "" or par2 ~= "" then -- if parameters arent nil then run command print(plr.Name.." ran command: '"..cmd.." "..par1.." "..par2.."'") -- print command ran to output -- Commands -- if cmd == "kick" then if par2 ~= "" or par2 ~= "[Parameter2]" then game.Players[par1]:Kick(par2) else game.Players[par1]:Kick() end end if cmd == "kill" then workspace[par1].Humanoid.Health = 0 end if cmd == "god" then if workspace[par1].Humanoid.MaxHealth == 100 then workspace[par1].Humanoid.MaxHealth = math.huge else workspace[par1].Humanoid.MaxHealth = 100 end end else print("Error: No parameters!") -- Error if no parameters are given end else print("Error: Invalid command") -- Error if command is invalid end else plr:Kick("Error: User is not admin! (Reason: DONT EXPLOIT AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!)") -- If the player isn't admin, kick him for exploitation end end)
Basically if i input the params for "kick" it works just fine, and I suspect its because its first in the table, however any other commands, aka god or kill just prints "Invalid Command". I know that the problem lies somewhere in the table, however I have no clue how to solve this issue, I'd be grateful to get an explanation.
--within the Chatted event local commands = { ['kill'] = function() game.Players[par1].Character:Breakajoints() end; ['gay'] = function() print'no u' end; } if commands[cmd] then commands[cmd]() end
Solved by annabet_h, thank you!