Admin loader not working

I am working on an admin loader. I have a modulescript for my admin script (that clones all my items like gui, etc into PlayerGui) and a script that loads the actual module.

Script code:

-- devinkid1's Admin Setup Script --
-- Do NOT reupload and say its your own please, thanks <3 --

local admins = {35643110}
require(5837129830):Setup(admins)

Modulescript code:

-- devinkid1's Admin Setup Module --
-- Do NOT reupload and say its your own please, thanks <3 --

local module = {}
local admins

function module:Setup(args)
	admins = args
	print("Setup Devin's Admin.")
end

game.Players.PlayerAdded:Connect(function(p)
	repeat wait() until admins
	if admins[p.Name] or admins[p.UserId] then
		local AdminGUI = script.AdminGUI:Clone()
		AdminGUI.System.ServerAdminSystem.Disabled = false
		AdminGUI.System.ClientAdminSystem.Disabled = false
		AdminGUI.Parent = p.PlayerGui
		print("Gave admin to " .. p.Name .. ".")
	end
end)

return module

It does setup correctly but it wont clone into the player’s PlayerGui.

Output: Setup Devin's Admin.

It is supposed to also say Gave admin to devinkid1.

Yes, my modulescript is named MainModule and yes, I am testing in client not studio.

1 Like

This is prob error. Did you check that and mark it working when its error?

Script code:

-- devinkid1's Admin Setup Script --
-- Do NOT reupload and say its your own please, thanks <3 --

local admins = {35643110}
local AdminSystem = require(5837129830)

-- Setup
AdminSystem:Setup(admins)

-- Player Events
game.Players.PlayerAdded:Connect(AdminSystem.GiveAdmin)

Modulescript code:

-- devinkid1's Admin Setup Module --
-- Do NOT reupload and say its your own please, thanks <3 --

local module = {}
local admins

function module:Setup(args)
	admins = args
	print("Setup Devin's Admin.")
end

function module.GiveAdmin(player) 
	repeat wait() until admins
	if admins[player.Name] or admins[player.UserId] then
		local AdminGUI = script.AdminGUI:Clone()
		AdminGUI.System.ServerAdminSystem.Disabled = false
		AdminGUI.System.ClientAdminSystem.Disabled = false
		AdminGUI.Parent = player.PlayerGui
		print("Gave admin to " .. p.Name .. ".")
	end
end)

return module

If it still doesn’t work then try to Insert the Module Script in the game then tweak your code, after that it should work

I checked and it works. The problem I am having is that PlayerAdded wont work in the modulescript.

Ok, I will try that. A thing to keep in mind is that I wanted the Playeradded to be in the modulescript. Are you able to have playeradded in modulescripts?

So I just fixed it, apparently I had to use table.find instead of admin[p.UserId].

1 Like