Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How can I make it so if I type not the entire username it can find that player?

Asked by 4 years ago

I'm trying to make this admin script and I'm trying to make it so I don't have to type the entire username so If I did typed "marioet77" full username it would work but if I typed "mario" then it wouldn't can you tell me how I could make this happen? Here's the code.

local remoteII = game.ReplicatedStorage.Remotezz

remoteII.OnServerInvoke = function(plr, CodeBox)
    local args = CodeBox:split(" ")
    if args[1] == "Tools" then
        for i,v in pairs(game.Players:GetPlayers()) do
            if v.Name:lower():match(args[2]:lower()) then
              function GetTools(a)
                if (a.className == "Tool") then
                  a:Clone().Parent = game.Players:FindFirstChild(args[2]).Backpack
                end
                local b = a:GetChildren()
                for i=1,#b do
                  GetTools(b[i])
                end
              end
            end

            GetTools(game.Players:FindFirstChild(args[2]).PlayerGui.Shh.Handle.Tools)
        end
    end
end

1 answer

Log in to vote
1
Answered by 4 years ago

It seems you are doing this to a certain extent, but wrong. You need to use string.match, and that's what you're doing. But then if mario matches marioet77 then you assume the player's name is mario. Instead of doing a:Clone().Parent = game.Players:FindFirstChild(args[2]).Backpack or GetTools(game.Players:FindFirstChild(args[2]).PlayerGui.Shh.Handle.Tools), replace game.Players:FindFirstChild(args[2]) with v. You already have the player, and you've confirmed it's the one you're looking for.

Reply with further questions,

and please mark as correct if this solution works for you!

Ad

Answer this question