ModuleScript Help

Ok, so I was scripting, and I know i’m being really dumb. (I’m new to modulescripts but I don’t think thats what is wrong)

local Config = require(script.KronosConfig)
local Admins = Config.Council_Members
local Handler = {}
Handler.AddGui = function addGui(player) --errors right here saying "excepted ( when parsing function, got addGui"
	newGui = script.Parent.Assets["GUI's"].MainGui:Clone
	end
return Handler

That is all I need help with, Figuring out what is causing that error.

Change this Handler.AddGui = function addGui(player) to this function addGui(player).

If I do that the it won’t be attributed to the handler.

Change

Handler.AddGui = function addGui(player) --errors right here saying "excepted ( when parsing function, got addGui"
	newGui = script.Parent.Assets["GUI's"].MainGui:Clone
end

to

Handler.AddGui = function(player)
	newGui = script.Parent.Assets["GUI's"].MainGui:Clone
end

because the function should be anonymous without a name when you assign it to a variable

Then try this:

function handler:addGui(player)

And when you want to call the function just do handler:addGui(player).

1 Like

ohhh, thanks @TokoNanami, that helps a lot!

You are assigning a variable to a named function, which will error, there are 2 things you can do

Handler.AddGui = function()
	...
end

or

function Handler.AddGui()
	...
end

I would recommend the second way.

1 Like

You all helped lots, Thank you.

1 Like