-
I have an edited version of the roblox playermodules to change a variable in one of my own modulescripts whenever shiftlock is enabled or disabled.
-
The playermodule seemingly cant find my own module, ive tried placing it in both replicatedstorage and replicatedfirst. I’ve tried using waitforchild and simply referencing it but i dont even get an error message or a yield warning, Its as if the module just freezes up when it gets to the variable requiring my module.
-
Everything listed above, ive also used print checks to narrow down the problem and i am absolutely sure the problem is the require statement for the module.
1. Ensure Module Placement
Ensure that your custom module is placed in a location that’s accessible to the client. Common locations include:
ReplicatedStorageReplicatedFirst
2. Correct Path and WaitForChild
When requiring your custom module, ensure you’re using the correct path and WaitForChild if necessary. For example:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local myModule = ReplicatedStorage:WaitForChild("MyModule")
local myModuleScript = require(myModule)
3. Verify Module Name
Double-check the name of your custom module to ensure it matches exactly (including case sensitivity) with what you are trying to require.
4. Debugging with Prints
Since you’ve used print checks, place a print statement just before the require statement to ensure the code execution reaches that point:
print("Attempting to require MyModule")
local myModuleScript = require(ReplicatedStorage:WaitForChild("MyModule"))
print("Required MyModule successfully")
5. Check for Errors
Ensure there are no errors within the custom module itself that might be causing the require to fail silently. You can add print statements at the start of the module to confirm it’s being executed:
-- Inside MyModule
print("MyModule loaded")
local MyModule = {}
-- Module implementation
return MyModule
6. Module Dependencies
If your custom module has dependencies on other modules or services, ensure those are available and correctly referenced.
7. Requiring in LocalScripts
If you’re modifying the PlayerModule which is a LocalScript, ensure that the custom module is accessible from the client side. Modules in ReplicatedStorage and ReplicatedFirst should be accessible.
8. Roblox ModuleScript Requirements
Ensure your custom module follows the standard module script requirements for Roblox:
- It returns a table or function.
- It does not have syntax errors.
Example
Here’s an example to illustrate:
Custom Module (MyModule)
-- MyModule located in ReplicatedStorage
print("MyModule loaded")
local MyModule = {}
function MyModule.DoSomething()
print("MyModule is doing something")
end
return MyModule
PlayerScript Modification
-- Inside a PlayerScript module
local ReplicatedStorage = game:GetService("ReplicatedStorage")
print("Attempting to require MyModule")
local myModule = ReplicatedStorage:WaitForChild("MyModule")
local myModuleScript = require(myModule)
print("Required MyModule successfully")
-- Using the custom module
myModuleScript.DoSomething()