PlayerModule can't be found

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like to access the PlayerModule:GetControls() function.

  2. What is the issue? Include screenshots / videos if possible!
    My script worked about 2 days ago. Today I packed the camera part into a new script and now I can’t access the PlayerModule:GetControls() function no more.

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I checked the developer hub and found nothing that helped. I disabled all other scripts that got changed to check if any other scripts are affecting this by accident. Nothing worked so far.

Error Message:
Screenshot 2023-07-06 164207

Full Script (New Script):

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

repeat wait() until game:IsLoaded()

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
controls:Disable()

game.StarterGui:SetCore("ResetButtonCallback", false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

Full Script (Old Script):

local player = game.Players.LocalPlayer
local defaultCam = game.Workspace.CurrentCamera
local partCam = game.Workspace:WaitForChild("CameraPart")
local viewCam = game.Workspace:WaitForChild("CameraViewport")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

local tweenSettings = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)

repeat
	wait(1)
until game.Loaded

local controls = require(player.PlayerScripts.PlayerModule):GetControls()
controls:Disable()

repeat
	defaultCam.CameraType = Enum.CameraType.Scriptable
	wait(1)
until defaultCam.CameraType == Enum.CameraType.Scriptable

defaultCam.CFrame = viewCam.CFrame	

game.StarterGui:SetCore("ResetButtonCallback", false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)

have u tried waiting just incase.

local controls = require(game:GetService("Players").LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetControls()
controls:Disable()
1 Like

Yes, just tried it again.

Result:

Infinite yield possible on ‘Players.MLGChaosreto.PlayerScripts:WaitForChild(“PlayerModule”)’ - Studio

if game:IsLoaded() == false then
	repeat task.wait() until game:IsLoaded()
end
local lplr = game:GetService("Players").LocalPlayer
local StarterGui = game:GetService("StarterGui")
local controls = require(lplr:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetControls()
controls:Disable()

repeat task.wait() until lplr.Character

StarterGui:SetCore("ResetButtonCallback", false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
print("done!")

Works well for me. Make sure its LocalScript and you put it inside ReplicatedFirst (cuz I tested it only in ReplicatedFirst).

1 Like

Tested this. The PlayerModule still can’t be found. Thx for your answer!

I also checked out a new place and for some reason it doesn’t create the PlayerModule in my actual game.

Maybe report that as an engine bug since that is not normal

I tested on empty baseplate no other scripts and it works. Maybe you changed some property or some script is calling :Destroy() on PlayerModule?

Just found the issue. I named one of my scripts CameraScript which broke the entire auto-generated script section. Thx for everybodys help!

2 Likes

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