Topic leading up to this issue:
How would i successfully split this table and convert it to a string
I’m trying to concatenate a table which has been split with a string, and its provoking the error in the title.
I’m not fully aware how table.concat works so this may be the reason why this is happening.
The section of the code handling this:
elseif Command == "J:Warn" then
print("Warning...")
local Target = ArgsTable[2]
if string.lower(Target) == "all" then
for indexPlayer, Player in pairs(game.Players:GetPlayers()) do
if Player == plr then
print("Will not warn, as target is admin")
else
local Head = Player.Character:WaitForChild("Head")
if Head then
local NewTable = table.remove(ArgsTable, 1)
local ToJoin = table.concat(NewTable, " ")
local WarningGuiClone = WarningBillboardGui:Clone()
WarningGuiClone.Text.Text = "You Have Been Warned For: "..ToJoin
local WarningGuiClone = WarningBillboardGui:Clone()
WarningGuiClone.Text.Text = "You Have Been Warned For: "..string.split(table.concat(stringMsg, ArgsTable[3][2], " "))
WarnEvent:FireClient(Player, ArgsTable[3])
Player:WaitForChild("Warns").Value += 1
if Player:WaitForChild("Warns").Value == MainModule.MaxWarns then
Player:Kick("You Have Been Warned Too Many Times")
end
delay(10, function()
WarningGuiClone:Destroy()
end)
end
end
end
else
local Found_Player = MainModule.FindClosestMatchString("PlayerSearch", game.Players:GetPlayers(), Target)
if Found_Player ~= nil then
local Head = Found_Player.Character:WaitForChild("Head")
if Head then
local NewTable = table.remove(ArgsTable, 1)
local ToJoin = table.concat(NewTable, " ")
local WarningGuiClone = WarningBillboardGui:Clone()
WarningGuiClone.Text.Text = "You Have Been Warned For: "..ToJoin
WarningGuiClone.Parent = Head
WarnEvent:FireClient(Found_Player)
Found_Player:WaitForChild("Warns").Value += 1
if Found_Player:WaitForChild("Warns").Value == MainModule.MaxWarns then
Found_Player:Kick("You Have Been Warned Too Many Times")
end
delay(10, function()
WarningGuiClone:Destroy()
end)
end
end
end
Module:
local mainTable = { --Table to store all functions, permited Players and valid commands
["permittedIDs"] = { ---Table to store IDs of all
366734064 --My User ID
},
["validCmds"] = { --Table to store all cmds, for checks
"J:Kick", --kick cmd
"J:Kill", --kill cmd
"J:Warn", --warn cmd
"J:Speed", -- speed cmd
"J:JumpPower", --jump cmd
"J:Insert", --tool inserrt cmd
"J:Fling" --fling cmd
},
["MaxWarns"] = 3 --Max warns before kick
}
local InsertService = game:GetService("InsertService")
--Functions--
function mainTable.FindClosestMatchString(typeofsearch, placeToSearch, String) --Search for closest match
String = string.lower(String) -- make it comparable
if typeofsearch == "PlayerSearch" then
if placeToSearch ~= game.Players:GetPlayers() then
placeToSearch = game.Players:GetPlayers() ---Not sure if neccessary, maybe if i make a mistake
end
for indexPlayer, Player in pairs(placeToSearch) do --pairs loop
if string.match(string.lower(Player.Name), "^"..string.lower(String)) then --return match
return Player
end
end
elseif typeofsearch == "CommandSearch" then
local CMDtable = placeToSearch
for indexCommand, Command in pairs(CMDtable) do -- pairs loop
if string.match(String, "^"..string.lower(Command)) then --return match
return Command
end
end
end
end
function mainTable.BreakUpStringIntoSpaces(String) --String.gmatch method
local Table = {}
for word in string.gmatch(String, "%S+") do -- %S+ is the string pattern to split up into spaces (Will change pattern later)
table.insert(Table, #Table +1, word)
end
return Table --return table full of broken up string
end
function mainTable.Instance(InstanceString, Destination, Name, InitalVal) -- Unneccessary, but I'm adding this anyway
local InstanceCreated = Instance.new(InstanceString) --Instance the thing defined
InstanceCreated.Parent = Destination --Parent it
InstanceCreated.Name = Name --set name
if InitalVal ~= nil then
InstanceCreated.Value = InitalVal ---Set value to val given
else
print("Not A Value")
end
return InstanceCreated --Make the part accessible
end
function mainTable.UnpackModel(Model, Destintation)
local Children = Model:GetChildren()
for indexChild, Child in pairs(Children) do
Child.Parent = Destintation
end
return Children
end
function mainTable.InsertTool(ID, Player)
local tool
local success, errormsg = pcall(function()
tool = InsertService:LoadAsset(ID)
end)
if success then
print("Success")
else
warn(errormsg)
end
local Character = Player.Character or Player.CharacterAdded:Wait()
if Character then
tool = mainTable.UnpackModel(tool, Character)
Character.Humanoid:EquipTool(tool:FindFirstChildOfClass("Tool"))
end
end
return mainTable --Make it accessible to scripts