I am trying to make an admin command script, and I have made a function that is supposed to get the owners name, which(I have not added this yet) will then insert the name into the Admins list.
I do not know why it is not working, and I am in need of help, here is the script.
local owner = game.CreatorId
local admins = {"NameHere","AnotherAdmin"}
-- Funcs
game.Players.PlayerAdded:connect(function(plr)
function GetOwnerName()
if plr.UserId == owner then
local x = plr.Name
end
end
local ownername = GetOwnerName()
local m = Instance.new("Message", workspace)
m.Text = ( ownername.. " has Joined the server")
end)
Any and all help is appreciated and needed.

2 comments
You should add that you can use "if adminList[plr.UserId] then print('isAdmin') end", no need to loop trough the table
I had been using the UserId of the game owner, as I was planning on making the Admin list into UserID, I just had not developed an admin commands EVER, so I was going to do a simple ideal first, then edit and keep editing as it went along.