Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Solved] Connection lines within ModuleScripts?

Hi. I have a function connected to MouseClick, which works outside of the module, but not inside of it. The rest of the module runs fine, but the connection doesn't fire. Can connection lines be used within ModuleScripts?

Example of what I mean:

Server Script:

local module = require(script.Parent.Module)
module.initialise()

Module:

local m = {}

function m.initialise()
	-- Definition of ClickDetector, etc etc
	click.MouseClick:connect(function()
		print("I was clicked, or something")
	end)
end

return m

I'd be able to do this easily without using the module, but it would be better if it could be contained in it. Thanks in advance!

2 comments

0

You need to require the module, so just change it to: local module = require(script.Parent.Module). That should fix it

0

I did in the actual script, typed this up as an example & forgot to require. Let me edit that in

1 answer

Aaaand solved, it was just me being an idiot; accidentally had one of the checks set to true rather than false.

This discussion is preserved as it was. New answers, comments, and votes are closed.