Cloning Admin Tool To a Specific Player

So i am making a admin tool but i’m using dictonary or table (whatever you guys call it) and i’m kinda stuck on this script. Can someone help me.

local players = game:GetService("Players")
local admintool = game.ServerStorage.Admin


local admins = {
	"ulric3456",
	"ulric345" -- Random Alt Account
}

game.Players.PlayerAdded:Connect(function()
	for i, v in ipairs(admins) do
		admintool:Clone().Parent = v.Backpack
	end	
end)

Any help is appreciated!

2 Likes

you can change it to

local players = game:GetService("Players")
local admintool = game.ServerStorage.Admin


local admins = {
	"ulric3456",
	"ulric345" -- Random Alt Account
}

game.Players.PlayerAdded:Connect(function(plr)
	for i, v in ipairs(admins) do
       if v == plr.Name then
		  admintool:Clone().Parent = plr.Backpack
       end
	end	
end)

Or you can change it to this:

--//Services
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

--//Variables
local AdminTool = ServerStorage.Admin

--//Tables
local admins = {
	"ulric3456",
	"ulric345",
}

--//Functions
Players.PlayerAdded:Connect(function(player)
	if table.find(admins, player.Name) then
		local Tool = AdminTool:Clone()
		Tool.Parent = player.StarterGear
	end	
end)
1 Like

it didnt work as intended but thanks for the help

it didnt work as ipairs or pairs

Sorry, I just edited my post, try my fixed script.

local players = game:GetService("Players")
local admintool = game.ReplicatedStorage.Admin -- MOVE YOUR ADMIN TOOL TO THE REPLICATED STORAGE.


local admins = {
	"ulric3456",
	"ulric345" -- Random Alt Account
}

game.Players.PlayerAdded:Connect(function(player)
	for i, v in pairs(admins) do
		if v == player.Name then
            admintool:Clone().Parent = player.Backpack
            break
        end
	end	
end)

move your tool to the replicated storage

and test this code

hope this works

sorry for the late reply, i got it to work

1 Like