Alright, so I figured out how to make a command with one player, but what about two? So the command I want to make is :tp. So if you want to know how it works, say like there is two players, Loot_0, and 0_tooL. Then, I say :tp lo 0_ and I get teleported to 0_tooL.
function findPlayer(r) for i, v in pairs(game.Players:GetPlayers()) do local n = v.Name:lower() if n:find(r) then return v end end end game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) if msg:sub(1, 4):lower() == ":tp " then local p = findPlayer(msg:sub(5):lower()) local p2 = findPlayer(msg:sub(7):lower()) if p and p2 then workspace[p.Name].Head.CFrame = workspace[p2.Name].Head.CFrame end end end) end) --Edit: Focus on lines 13 and 14 --I typed most of this on here, so there might be mistakes.
On line 13, I know it wouldn't work because if I said :tp loot 0_to, it would try to find a player called "loot 0_to". And for line 14, it also wouldn't work cause p
would have to be one letter long. So, again, how would I make a chat cmd with two players?
The best option would be string.split.
Read more here: https://developer.roblox.com/en-us/api-reference/lua-docs/string
You will want to split on the space character. You could then transform the command into this:
tp [Player1] [Player2]
That would return a table containing 3 values. You could then reference the 2nd and 3rd value and find the player(s) based on those.
Hope this helped, and good luck on whatever you are trying to make.
If this doesn't work, leave a comment.