Hello, I am trying to make an admin command script where you can type something like ;s print'hi'
and It would print to the console. The problem is that the string would just show up as nothing even when I print it. (Also I do have LoadStringEnabled) Heres my code:
local Commands = {
[";kick"] = {Type = 2, Function = function(Message, Reason)
local Player = FindPlayerFromMessage(Message)
Player:Kick(Reason)
end};
[";s"] = {Type = 5, Function = function(Message)
local s, e = pcall(function()
assert(loadstring(Message))()
end)
if not s then warn(e) end
end};
}
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if GroupRank >= 254 then
Message = string.split(Message, " ")
local Command = Message[1]
local Parameter = Message[2]
local Parameter2 = Message[3]
if Commands[Command] then
if Commands[Command].Type == 1 then
local s, e = pcall(function() Commands[Command].Function(Parameter) end)
if not s then warn(e) end
elseif Commands[Command].Type == 2 then
local s, e = pcall(function() Commands[Command].Function(Parameter, Parameter2) end)
if not s then warn(e) end
elseif Commands[Command].Type == 3 then
local s, e = pcall(function() Commands[Command].Function(Player, Parameter, Parameter2) end)
if not s then warn(e) end
elseif Commands[Command].Type == 4 then
local s, e = pcall(function() Commands[Command].Function(Player) end)
if not s then warn(e) end
elseif Commands[Command].Type == 5 then
local new = unpack(Message) --problem is here
print(string.sub(new, 4)) -- It would just print "" an empty string
local s, e = pcall(function() Commands[Command].Function(string.sub(new, 4)) end)
if not s then warn(e) end
end
end
end)
end)
Can anyone help? Thanks!