Well, I’ll give you a little information, I’m making a tower of hell type game but the problem comes when I try to verify if the command is valid or not, I’ve tried everything and it doesn’t work because even if I run the valid command it sends the message to the chat and I do not know what to do.
The problem comes from the
local commandScript = Commands:FindFirstChild(cmd)
if commandScript then
spawn(function()
require(Commands[cmd]).run(plr, message, args)
end)
else
errorMessage = "[Command]: There is no such command, commands '/skip', '/setlength'"
sendMessage(plr, errorMessage)
return
end
Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(message)
local errorMessage = ""
if not table.find(permissions, plr.UserId) then
if message:sub(1, #prefix) == prefix then
errorMessage = "[Command]: you do not have permission to use this command"
sendMessage(plr, errorMessage)
return
end
end
if message:sub(1, #prefix) ~= prefix then
errorMessage = "[Command]: use "..prefix.." to be able to use the command"
sendMessage(plr, errorMessage)
return
end
local args = message:split(" ")
local cmd = args[1]:sub(#prefix + 1):lower()
table.remove(args, 1)
local commandScript = Commands:FindFirstChild(cmd)
if commandScript then
spawn(function()
require(Commands[cmd]).run(plr, message, args)
end)
else
errorMessage = "[Command]: There is no such command, commands '/skip', '/setlength'"
sendMessage(plr, errorMessage)
return
end
end)
end)
I hope you can help me