Hey there, I am making my own admin commands and I want to be able to find the player from their partial name instead of typing a player’s full username.
--// FUNCTIONS
local function PartialName(PartialName)
local FoundPlayer = nil
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local CurrentPlayer = Players[i]
if string.find(string.lower(CurrentPlayer.Name), string.lower(PartialName)) then
FoundPlayer = CurrentPlayer.Name
end
end
if not FoundPlayer then
return nil
else
return FoundPlayer
end
end
--// Speed Command
Commands.speed = function(player, args)
if args[1] == "me" then
if tonumber(args[2]) then
player.Character.Humanoid.WalkSpeed = args[2]
end
else
for i, v in pairs(Players:GetPlayers()) do
if string.lower(PartialName(v.Name)) == args[1] then
local PlayerToSpeed = v
print(v)
PlayerToSpeed.Character.Humanoid.WalkSpeed = args[2]
end
end
end
end
I have gave this a go, however it didn’t work and I don’t know how I could do this. Any help will be appreciated.