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.
01 | local remoteII = game.ReplicatedStorage.Remotezz |
02 |
03 | remoteII.OnServerInvoke = function (plr, CodeBox) |
04 | local args = CodeBox:split( " " ) |
05 | if args [ 1 ] = = "Tools" then |
06 | for i,v in pairs (game.Players:GetPlayers()) do |
07 | if v.Name:lower():match(args [ 2 ] :lower()) then |
08 | function GetTools(a) |
09 | if (a.className = = "Tool" ) then |
10 | a:Clone().Parent = game.Players:FindFirstChild(args [ 2 ] ).Backpack |
11 | end |
12 | local b = a:GetChildren() |
13 | for i = 1 ,#b do |
14 | GetTools(b [ i ] ) |
15 | end |
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!