I have a local script called ControlsScript and a module script called InputMode both inside of StarterPlayerScripts.
Inside of ControlsScript, at the start of the script it does:
local PlayerScripts = Players.LocalPlayer.PlayerScripts
local InputMode = require(PlayerScripts.Controls.InputMode)
When I run the game, the second line spits out the error saying Controls is not a valid member of Players.LocalPlayer.PlayerScripts
I tried printing the children of PlayerScripts before requiring the module and it appears only a few of the scripts have been added to PlayerScripts by the time this script runs, whereas adding a wait() beforehand would show all the scripts loaded and the module would be found and loaded perfectly fine.
print(PlayerScripts:GetChildren())
wait()
print("waited")
print(PlayerScripts:GetChildren())
local InputMode = require(PlayerScripts.Controls.InputMode)
local Enumerate = require(RepStore.Services.Enumerate)
This solution isn’t sufficient for me since this script creates a CharacterAdded event, and adding a wait() causes it to run after the Character is autoloaded. Is there any way to ensure all the script instances are added before they run?