Hello. I am trying to make admin commands for my game, and I would like to know how to get the character from the message. Here is my code.
if args[1] == prefix.."teleport" then
args[2].Character.HumanoidRootPart.CFrame = args[2].Character.HumanoidRootPart.CFrame + Vector3.new(0,3,0)
end
The args and prefix variable are defined above.
Assuming you wanted to use an abbreviation for your second argument you could use a function like this to check if player exists from the abbreviation you gave in the second argument and then handle teleportation from there.
local function getPlayerFromAbbreviation(abv)
for _,v in pairs (game:GetService("Players"):GetPlayers()) do
if string.sub(string.lower(v.Name), 1, string.len(abv)) == string.lower(abv) then
return v
end
end
return nil
end
wait(5)
print(getPlayerFromAbbreviation("azl").Name) -- "azlentic"