PlayerModule cannot be found

I’m trying to disable controls for the player. From what I’ve read you need to get the playermodule and then get the controls. When doing that, the PlayerModule cannot be found for some reason.

local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"):GetControls())
Infinite yield possible on 'Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")'

I created a blank studio file and dragged a playermodule in, but now it just prints: GetControls is not a valid member of ModuleScript "Players.youbigown.PlayerScripts.PlayerModule"
Did they recently change how to get controls of a player?
image

1 Like
local Controls = require(LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"):GetControls())

You are calling a function inside the require which is wrong because there arent any methods called “GetControls”

what i think you wanted to do is this

local Controls = require(LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
1 Like

Looks like it can find the GetControls now, however it complains when there is no cameramodule.

The thing is I have a custom camera so if the cameraModule exists, then the customcamera stops working.

Infinite yield possible on 'Players.youbigown.PlayerScripts.PlayerModule:WaitForChild("CameraModule")'

Also I can still control my character after calling the Controls:Disable() even if the cameraModule exists…

uhm, its strange… i dont really worked with the PlayerModule but can u send the script so i can know what is going on?

full script (local)

local cc = game.Workspace.CurrentCamera
local StarterGui = game:GetService("StarterGui")
local LocalPlayer = game:GetService("Players").LocalPlayer
local Controls = require(LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()

game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.C then
		if cc.CameraType == Enum.CameraType.Custom then
			cc.CameraType = Enum.CameraType.Scriptable
			Controls:Disable()
		end
	end
end)

game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.Return then
		if cc.CameraType == Enum.CameraType.Scriptable then
			cc.CameraType = Enum.CameraType.Custom
			Controls:Enable()
		end
	end
end)

the script seems fine, what i understanded earlier was that the camera only works when the camera module doesnt exist (which is kind of strange, idk if u actually deleted the module or not) but now, i have a question your camera by default is already on Custom?

It is already custom yes
image

Uhm this is actually pretty strange, i kinda strugglin into this rn lol

1 Like

ok if I place camereascript inside playermodule it actually disables/enables movement correctly from my current testing.

However the custom camera doesn’t work anymore :confused:
Looks like this method of stopping character movement just doesn’t work when you have a customCamera

do you have any suggestions on locking the character in place after pressing C?

I tried anchoring the humanoidrootpart, but if you are in the air then you are stuck while chatting which could be a very overpowered ability in some situations

I also tried setting humanoid’s walkspeed to 0, but if the player moves and clicks C, then it just automoves

uhm i think the only way to stop the player is just walkspeed if disabling controls doesnt work, i used it a lot of times, just try to implement it well

1 Like

Ok so I am kind of dumb in relation to the walkspeed solution.
My other script keeps changing the speed of the humanoid, so I just needed to add an if statement to make sure that chat isn’t opened.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.