Help with message splitting

I want to make my split work

The message splits with " " but then I cannot make my message because it will split it with " ".

Nothing

I am trying to make admin commands with my chatted event but the message splits when someone adds a " ". But I really want it to be able to make a message like this:

Hello I am Text String!!!

But instead I would get this:

Hello

You see I am trying to make my message command to where I can make a message but when I try it, it just splits the " " when I am on the second argument. I would also like you to know that my code is from Alvin_Blox’s tutorial since I do not fully know admin commands and that he made it poorly so when I do message:split(" ") it splits my message I am sending on my GUI

--WARNING ALL OF THIS CODE NEEDS TO STAY HERE I JUST NEED THE " " SPLITTING PART FIXED
Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		local Message = Message:lower()
		
		local splitstring = Message:split(" ")
		
		local slashCommand = splitstring[1]
		
		local cmd = slashCommand:split(Prefix)
		
		local cmdName = cmd[2]
		
		if CommandsTable[cmdName] then
		
			local args = {}
			
			for i = 2,#splitstring,1 do
				table.insert(args,splitstring[i])
			end
			
			CommandsTable[cmdName](Player,args)
			
		end
	end)
end)

I’m very confused in what you’re trying to achieve, could you explain this further.

I just edited it please tell me if you need more but I do not know much more I can add

Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		Message = string.lower()
		
		local splitstring = Message:split(" ")
		
		local slashCommand = splitstring[1]
		
		local cmd = slashCommand:split(Prefix)
		
		local cmdName = cmd[2]
		
		if CommandsTable[cmdName] then
		
			local args = {}
			
			for i = 2,#splitstring,1 do
				table.insert(args,splitstring[i])
			end
			
			CommandsTable[cmdName](Player,args)
			
		end
	end)
end)

the Message = string.lower() part would error as a string is needed in the first parameter when using string.lower

It is the exact same code other than string.lower but :lower() is just the same but without string.lower

1 Like

Lemme test right now :grinning_face_with_smiling_eyes:

Becuase It splits my message gui I will send screenshot in a sec

@itsfate0
image
See it splits/cuts my message becuase I added a space

CommandsTable[cmdName](Player,table.concat(args, " ")) try this

Do I also delete message:split(" ")

1 Like

Now my command does not work what so ever

1 Like

no you wouldn’t need to, show me the function of the command

Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		local Message = string.lower(Message)
		
		local splitstring = Message:split(" ")
		
		local slashCommand = splitstring[1]
		
		local cmd = slashCommand:split(Prefix)
		
		local cmdName = cmd[2]
		
		if CommandsTable[cmdName] then
		
			local args = {}
			
			for i = 2,#splitstring,1 do
				table.insert(args,splitstring[i])
			end
			
			CommandsTable[cmdName](Player,table.concat(args," "))
			
		end
	end)
end)

the function of the command (show me the CommandsTable table)

local CommandsTable = {} --// It has the commands below it they work fine until I added table.concat

i need to see the actual command so i can see what you’re doing with the args

I don’t get what your trying to do here, can you explain more clearly?

--// Client Commands \\--
CommandsTable.message = function(sender,args)
	
	local messageToSend = args[1]
	
	if messageToSend then
		for i,obj in pairs(Players:GetPlayers()) do
			local ClientClone = LocalCodeExecutor:Clone()
			ClientClone.Parent = obj:FindFirstChild("PlayerGui")
			ClientClone.Disabled = false
			ClientClone.MessageGui.BackgroundFrame.Message.Text = tostring(messageToSend)
			wait(0.25)
			ClientClone.Command.Value = "message"
		end
	end
end

--It is messy sorry but does work

local messageToSend = table.concat(args, " "); you can use what you sent in the first post with this

1 Like