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?

2 comments
Use the HumanoidRootPart and SetPrimaryPartCFrame to move Characters. Your findPlayer function may possibly be having troubles matching the usernames to each player as string.find will locate similar characters within both of them.
I updated the script so it works much better.