Error: attempt to index nil with 'SetIsMouseLocked'

can you tell me what this prints, and also after the wait(1)

local PlayerModule = player.PlayerScripts:WaitForChild("PlayerModule")	
local mouseLock = require(PlayerModule.CameraModule).activeMouseLockController
print(mouseLock)
wait(1)
print(mouseLock)

Edit: what if you just tried this

player.DevEnableMouseLock = false
1 Like

Both of them are nil.

If I only use DevEnableMouseLock then if the player already had the shiftlock enabled, it won’t be disabled (DevEnableMouseLock only enables/disables the toggle function).

1 Like

CameraModule:GetCameras() returns a blank table right now, there are no members (properties or functions). You will need to explicitly fork CameraModule to return the Camera singleton.

3 Likes

so you can just copy the PlayerModule then paste it into the StarterPlayerScripts and it works?

1 Like

Correct. Roblox will not inject the default PlayerModule if you include one in StarterPlayerScripts, so the PlayerScriptsLoader that gets injected will see and require your fork instead of a PlayerModule also injected by the client at run time.

2 Likes

So I should just remove the “return cameraapi” line?

Alright, then @HaxxerVaxxer can just download this file and paste it into StarerPlayerScripts right?
PlayerModule.rbxm (108.5 KB)
I just saved the PlayerModule to file then pasted it here

1 Like

Ok, what if you download that file, paste it into StarterPlayerScripts then tried this code

what prints?

1 Like

Same (nil, nil). I already had PlayerModule in StarterPlayerScripts. What does it mean a module to be “forked”?

take the code then modify it or whatever you want to do. What i told you to do is fork the PlayerModule (copy it then paste). Then require that forked module instead of the Default module

1 Like

I did what @colbert2677 said and it worked perfectly (also, I used my old script).
Anyways, thank you for really trying to help me!

1 Like