Command not working how it should be

  1. What do you want to achieve?
    I am making admin commands when someone says “!lock room b”, it will set CanCollide of the door b true

  2. What is the issue?

I was trying to add some print and stuff like that and i realised that it was working only when i add a space at the end of “!lock room b”

  1. What solutions have you tried so far?
    Like i said before i added some print and knew what the problem but i dont know how to solve it.

This is when i dont add a space it printed nothing

When i add a space at the end it works somehow

Sorry i couldnt screenshot it at the right moment so i recorded and screenshoted it, however we can see that it printed “You said room a” when i add a space at the end

heres the script:

local commands = {}

local prefix = "!"

function looptrough(model,boolean)
	for _,v in pairs(workspace[model.Name]:GetChildren()) do
		v.CanCollide = boolean
	end
end


commands.lock = function(arg,sender)
	local s,e = pcall(function()
		if arg[1] == "room" then
			if arg[2] == "a" then
				print('You said room a')
			end
		end
	end)
	if not s then
		error(e)
	end
end
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(m,r)
		m = string.lower(m)
		local splitString = m:split(" ")
		local cmd = splitString[1]
		local cmdname = cmd:split(prefix)
		if commands[cmdname[2]] then
			local args = {}
			
			for i = 2,#splitString,1 do
				table.insert(args,splitString[i])
			end
			
			commands[cmdname[2]](args,plr)
		end
	end)
end)

Thanks for reading

Is it a new update lua made? (30 chars)