I have a module script that connects to an admin script that I wrote. My module script code is:

local module = {}

function module:Message(announcer, message)
	script.Parent.Announcer.Text = announcer..":"
	script.Parent.Message.Text = message
	wait(15)
	script.Parent:Destroy()
end

return module

From my server script, I call:

local function serverMessage(announcer, message)
	local msgGui = script.ScreenGui
	for i, player in pairs(game.Players:GetPlayers()) do
		local playerGui = msgGui:Clone()
		playerGui.Parent = player.PlayerGui
		local msgModule = playerGui.Frame.ModuleScript
		msgModule:Message(announcer, message)
	end
end

And it errors saying that Message is not a valid member of ModuleScript. How do I fix this?

7 comments

0

Instead of the " : " in your module function, use a period so it should look like this: function module.Message.

0

Also, the same thing with the msgModule.Message

0

Still getting Message is not a valid member of ModuleScript

0

You also need to require the module script

0

Line 6 of the Server Script, change it to: local msgModule = require(playerGui.Frame.ModuleScript) and that should work. You can keep the : it doesn't matter if you use : or a .

0

instead of pointing to the module script directly, place your local msgModule line at the top folled by the require. So it'll look like this: local msgModule = require(playerGui.Frame.ModuleScript)

0

Oh I did not know you could use : or a. interchangeably, learned something new :)