Hello fellow dev people!! I have been racking my brain on how to fix this system I made off a tutorial (But I change it a bit)
-
What do you want to achieve? I have used a tutorial, I am not sure what happened. (I did ask the maker of it for some help, and they aren’t sure on how to fix it)
-
What is the issue? I have put the 3 scripts down the bottom.
-
What solutions have you tried so far? I have tried to fix it, but some of the script I am struggling to understand parts of the system. I have asked the tutorial creator but he doesn’t know how to fix it either.
There is 1 error that shows up when you type a command.
ServerScriptService.CommandsMain.CommandsManager:5: attempt to concatenate string with nil - Server - CommandsManager:5
CommandsMain (Script) Inside the ServerScriptService
local CommandManager = require(script.CommandsManager)
local actions = require(script.Actions)
game:GetService("Players").PlayerAdded:Connect(function(chatter)
chatter.Chatted:Connect(function(message)
if (message:sub(1,1) == "!") then
local tabL = message:split(" ")
tabL[1] = tabL[1]:lower()
CommandManager.add{tabL, chatter, "speed", {true, true, true, true, false}, actions.speed}
CommandManager.add{tabL, chatter, "jumppower", {true, true, true, true, false}, actions.jump_power}
CommandManager.add{tabL, chatter, "setHeatlh", {true, true, true, true, false}, actions.setHealth}
CommandManager.add{tabL, chatter, "setGrav", {true, true, true, true, false}, actions.setGrav}
CommandManager.add{tabL, chatter, "heal", {true, true, true, true, false}, actions.heal}
CommandManager.add{tabL, chatter, "kill", {true, true, true, true, false}, actions.kill}
CommandManager.add{tabL, chatter, "damage", {true, true, true, true, false}, actions.damage}
CommandManager.add{tabL, chatter, "reset", {true, true, true, true, false}, actions.reset}
-- If you really want to, you can make the command from inside:
CommandManager.add{tabL, chatter, "kick", {true, true, true, true, false}, function(plr, arg2)
plr:Kick("You've been kicked using admin commands")
end}
end
end)
end)
Action (ModuleScript) Inside the Commands Main script)
local actions = {}
function getCharacter(plr)
return (plr.Character or plr.CharacterAdded:Wait())
end
actions.speed = function(plr, speed)
if(tonumber(speed)) then
local char = getCharacter(plr)
char:WaitForChild("Humanoid").Walkspped = tonumber(speed)
end
end
actions.jump_power = function(plr, value)
if(tonumber(value)) then
local char = getCharacter(plr)
char:WatiForChild("Humanoid").JumpPower = tonumber(value)
end
end
actions.setHealth = function(plr, health)
if(tonumber(health)) then
local char = getCharacter(plr)
char:WaitForChild("Humandoid").Health = tonumber(health)
end
end
actions.setGrav = function(plr, grav)
if(tonumber(grav)) then
workspace.Gravity = tonumber(grav)
end
end
actions.heal = function(plr)
local char = getCharacter(plr)
char:WatiForChild("Humanoid").Health = char:WaitForChild("Humanoid").MaxHealth
end
actions.kill = function(plr)
local char = getCharacter(plr)
char:WaitForChild("Humanoid").Health = 0
end
actions.damage = function(plr, value)
if(tonumber(value)) then
local char = getCharacter(plr)
char:WatiForChild("Humanoid").Health = char:WaitForChild("Humanoid").Health - tonumber(value)
end
end
actions.reset = function(plr)
plr:LoadCharacter()
end
return actions
CommandsManager (Module Script) Inside the Commands Main
local CommandManager = {}
function CommandManager.add(tabL, plr, trigger, affectsWho, func, list)
warn(tabL,tostring(plr),trigger)
[ERROR OCCURS HERE] if(tabL[1] == "!" .. trigger) then
if (tabL[1] == "!" .. trigger) == not nil then
if(tabL[2] == nil and affectsWho[1]) then
func(plr)
elseif(tonumber((tabL[2])) ~= nil and affectsWho[1]) then
func(plr, tabL[2])
elseif(tabL[2] ~= "me" and tabL[2] ~= "others" and tabL[2] ~= "all" and not CommandManager:FindPlayer(tabL[2]:lower()) and affectsWho[1]) then
func(plr, tabL[3])
elseif(tabL[2] == "me" and affectsWho[1]) then
func(plr, tabL[3])
elseif(tabL[2] == "all" and affectsWho[2]) then
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
func(v)
end
elseif(tabL[2] == "others" and affectsWho[3]) then
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if(plr ~= v) then
func(v)
end
end
elseif(tabL[2] ~= "me" and tabL[2] ~= "others" and tabL[2] ~= "all" and affectsWho[4]) then
local cPlr = CommandManager:FindPlayer(tabL[2])
if(cPlr) then
func(cPlr, tabL[3])
end
elseif(affectsWho[5] and not affectsWho[1]) then
func(plr)
end
end
end
end
-- find player from a short name
function CommandManager:FindPlayer(who)
if (type(who) == "string") then
who = who:lower()
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
local name = v.Name:lower()
if(name:sub(1, #who) == who) then
print("Found: " .. name)
end
end
end
end
return CommandManager