Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Solved] Connection lines within ModuleScripts?

Asked by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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!

0
You need to require the module, so just change it to: local module = require(script.Parent.Module). That should fix it TheDeadlyPanther 2460 — 8y
0
I did in the actual script, typed this up as an example & forgot to require. Let me edit that in Pyrondon 2089 — 8y

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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

Ad

Answer this question