My script that checks if a user is on a certain list seems not to work. Any help?!
local mps = game:GetService("MarketplaceService")
local users = game:GetService("Players"):GetChildren()
return function(allowed)
if mps:UserOwnsGamePassAsync(game.CreatorId, 9122725) then
print('AdminSystems™️ - Enterprise Loaded!')
while wait(1) do
for _, v in pairs(users) do
if v.Name == allowed then
if v.PlayerGui:WaitForChild("AdminGUI") then
print("AdminSystems™️ - User Has GUI")
else
script.AdminGUI:Clone().Parent = v.PlayerGui
end
end
end
end
else
print('AdminSystems™️ - Game Owner Does Not Own The System! - Enterprise')
end
end
Connect the event then iterate over Players:GetPlayers() by calling the function with said player
--Handle players already in the game
for _, v in pairs(Players:GetPlayers()) do
OnPlayerAdded(v)
end
Players.PlayerAdded:Connect(OnPlayerAdded) --future event calls
local function OnPlayerAdded(plr)
print(plr.Name .. " joined the game")
end
for _, v in pairs(allowed) do
OnPlayerAdded(v)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
But then I get this error:
I also then tried
local function OnPlayerAdded(plr)
script.AdminGUI:Clone().Parent = plr.PlayerGui
end
for _, v in pairs(allowed) do
OnPlayerAdded(v)
end
Players.PlayerAdded:Connect(OnPlayerAdded)