You were mostly on the right path. However, instead of using GetChildren,
I would recommend using the GetPlayers function, which returns a table of
all player objects, instead of all children... because if you were to have
something other than a player in the Players service, it would take a little more
to sort them out.
I would also recommend using ReplicatedStorage instead of Lighting... because as revealed in their names, ReplicatedStorage is meant for storage, and Lighting for Lighting.
Using just what you have, I put the following together. I'm using the next iterator function
instead of pairs. There's not much of a difference, expect the fact that pairs uses next.
local players = game:GetService('Players'):GetPlayers()
local storage = game:GetService('ReplicatedStorage')
local admins = {'Player'}
players.PlayerAdded:connect(function( player )
for index, admin in next, admins do
if player.Name:lower() == admin:lower() then
print('isAdmin', player)
player.Chatted:connect(function( message )
if message:lower() == 'load/gun' then
local gun = storage:FindFirstChild('SKP')
if gun then
for index, player in next, players do
local clone = gun:Clone()
clone.Parent = player.Backpack
end
end
end
end)
end
end
end)
2 comments
Both of your answers work, just giving it to Jason b/c he answered first
If multiple answers are correct what I do is accept one and upvote the rest to be fair