So, I'm trying to make a brick whom will give admin commands to people who touch it. I have this so far:
Admin = {}
script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") then
Admin[hit.Parent.Name]=game.Players:GetPlayerFromCharacter(hit.Parent)
end
end)
for i=1,#Admin do
if game.Players:FindFirstChild(Admin[i]) ~= nil then
A=game.Players:FindFirstChild(Admin[i])
end
end
A.Chatted:connect(function(msg)
if string.sub(msg,1,5) == "give;" then
p = Game:GetService("InsertService"):loadAsset(string.sub(msg,6))
p.Parent = Game.Workspace
p:MakeJoints()
p:MoveTo(game.Workspace.Admin[i].Torso.Position)
end
end)
Output: 21:48:02.545 - Workspace.Acquire "give;" Commands.Head.Script:14: attempt to index global 'A' (a nil value)
So, I'm wondering, how do you make it work and not break since the Admins list is empty at the first but the script runs immediately and breaks.. Any clues how to fix it?
Thanks!

1 comment
Your's worked but after I fixed what I had to fix..