local player = game.Players.LocalPlayer local prefix = "." player.Chatted:Connect(function(msg) local target if msg:lower():match("goto") then if game.Players:FindFirstChild(msg:sub(6)) then target = workspace:FindFirstChild(msg:sub(6)) print(target) player.Character.HumanoidRootPart.CFrame = CFrame.new(target.Head.Position) end end end)
You need to expand on your string pattern.
The prefix you wish to use is considered a "magic character", so you will need to escape the dot to ensure it is evaluated literally. This is done with the %
character. Furthermore, you can use string captures to eliminate the need for string:sub
.
-- "^" ensures the pattern occurs at the beginning of the string. See the -- hyperlink to get a better understanding of the full pattern. local Arguments = (".goto Ziffixture"):match("^%.goto (.+)") if Arguments then print(Arguments) --> "Ziffixture" (Match was successful) end