Roblox Module scripts are structured differently than the wiki examples? Are they the same or am I doing it wrong?


It show that we structure modules like this

local my_functions = {}
    -- Add a few functions to the table
 return my_functions

And call them like this

local my_functions = require(script.Parent.MyFunctions)

But in the roblox player module it’s structured like this

function MouseLockController:OnMouseLockToggled()
--stuff here

If I wanted to fire this function OnMouseLockToggle() how would I do it?
Here’s what I have in a local script to test if this can fire

local MouseLockController = local MouseLockController = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("CameraModule"):WaitForChild("MouseLockController"))

It’s giving me the error: PlayerScripts.PlayerModule.CameraModule.MouseLockController:161: attempt to index nil with ‘Fire’

Sorry had to make an edit, my first error was because I forgot to include CameraModule, but even with it i still get a new error

The MouseLockController module uses object oriented programmng which you can view about here All about Object Oriented Programming . This means you’d have to do something like this :

local player = game:GetService("Players").LocalPlayer

local MouseLockController = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"):WaitForChild("CameraModule"):WaitForChild("MouseLockController"))
local newMouseLockController =

I don’t recommend doing this though as it might break something. Is there a specific reason you need to access this module?

I’m trying to have a way I can disable and enable a player’s in-game shift lock manually.