local maps = game.ReplicatedStorage.Maps
local player = game.Players.LocalPlayer
local mapcommand = "!load"
player.Chatted:connect(function(Chat)
if Chat:lower():sub(1,mapcommand:len()) == mapcommand then
local newMap = maps:FindFirstChild(Chat:sub(Chat,1+mapcommand:len()))
print(newMap)
end
end)
The purpose of this script is to take a command a player chatted, find the map they wish to load, and then print the map's name.
Players.Player1.PlayerGui.System Messages:148: bad argument #1 to 'sub' (number expected, got string)
Help would be greatly appreciated!

3 comments
It needs to be chat:sub() not chat.sub() on line 7.
Thanks for pointing that out. Still doesn't work though.
Is it a local or regular script? Where is it located in the game?