Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- module.createHandler = function(prefix, wl)
- local handler = {}
- handler.prefix = prefix
- handler.commands = {}
- handler.createCommand = function(name, callback)
- table.insert(handler.commands, {name, callback})
- end
- local function checkIfCommand(plr, msg)
- do --CheckPlr
- if wl ~= "all" then
- if typeof(wl) == "Instance" then if wl:IsA("Team") then if plr.Team ~= wl then return end end if wl:IsA("Player") then if plr ~= wl then return end end
- elseif typeof(wl) == "table" then local y = false for i, v in pairs(wl) do if v == plr.UserId then y = true end end if y == false then return end
- elseif typeof(wl) == "string" then if plr.Name ~= wl then return end
- elseif typeof(wl) == "number" then if plr.UserId ~= wl then return end end
- end
- end
- local args = string.split(msg, " ")
- local prefix = args[1]
- table.remove(args, 1)
- for i, v in pairs(handler.commands) do
- if string.lower(prefix) == handler.prefix .. string.lower(v[1]) then
- v[2](plr, args)
- return
- end
- end
- end
- --[[ PLAYER LOOP :]] for i, v in pairs(game:GetService("Players"):GetPlayers()) do v.Chatted:Connect(function(msg) checkIfCommand(v, msg) end) end game:GetService("Players").PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) checkIfCommand(plr, msg) end) end)
- return handler
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement