Rewrite the PlayerModule to be more readable and less disorienting

To clarify, the issues I discuss about are from the PlayerModule used when Workspace.PlayerScriptsUseInputActionSystem is enabled.

As a Roblox developer, I find it very difficult to use the Roblox-provided PlayerModule within my experiences. Sometimes I have to figure out what some parts of the PlayerModule are doing so I have to go on a wild goose chase in order to figure it out.

The PlayerModule desperately needs a rewrite. It has so many issues with it that make it so much harder to understand what the scripts are actually doing. Even with the IAS update, which helped clean up some of the input code, there are still a lot of problems, some even introduced with the update. Some of those issues include:

  • Horrendous type checking.
    • There are 600+ type errors in the PlayerModule if all the scripts used strict mode.
    • CommonUtils completely kills all of the type checking for the utility modules within it, and it is the cause of some type errors.
  • Having utility functions that serve no good purpose.
    • CharacterUtil.getLocalPlayer() is literally just getting Players.LocalPlayer and CharacterUtil.onLocalPlayer() is literally just if Players.LocalPlayer then
  • Nonsense that is just there for the sake of being there.
    • What the hell is the point of CameraModule.CameraUI??? it can literally be scripted out entirely.
  • Overcomplicating some things.
    • playerData.moveVector and playerData.isJumping are only used by ActionController.update, ControlModule::Update, and ClickToMoveController::Update. Can’t you just run the ClickToMoveController::Update method which already fires the InputActions anyways and then make variables to store the states of the MoveAction and the JumpAction in ControlModule::Update without having to store it in the playerData?
    • ControlModule::calculateRawMoveVector isn’t needed (at least for platforms that aren’t VR) because of Player:Move(insert something here, true) already doing what calculateRawMoveVector does.

Many people use the default PlayerModule. If a developer would have to read through the PlayerModule to figure something out, they would have to look through all of this mess. If they have to fork the PlayerModule, they would also have to deal with all of this mess. The PlayerModule does not feel developer friendly.

If the PlayerModule were rewritten to use good type checking, have a good structure, not contain any unnecessary fluff, and be friendly for developers to read, it would help me and other developers use the PlayerModule in their projects. It would also remove some of the effort it would take to fork the PlayerModule and change it to how you want it to act.

11 Likes

It’s also in desperate need of optimization. Not too unrealistic of a ballpark that it does maybe 50 metamethod calls, per frame…

@Yarik_superpro

7 Likes

It doesn’t need just a rewrite
it needs architectural rethinking
When I was writing my lightweight version of PlayerModule (FPX), I was so pissed off by how much OOP and performance overhead were present for the sake of it that it’s no longer even funny for a satire
Having an entire stack of performance-taxing class chains just to return one value is insane
For a rewrite to be good, they need to ENTIRELY remove ALL OOP or other “signal” bloat
And if they want modification, rely on upvalues or callbacks
It’s much better to expose function editing up values than read the table EVERY DAMN FRAME

Besides, PlayerModule should be focusing on developers editing it rather than runtime “callbacks” or whatever.
I already know that nothing ever happens, so hoping here is foolish

3 Likes

hello, my opinion should be powerful because I classify myself as a beginner programmer even though I developed on roblox studio for more (reason: I don’t really practice coding, but I promise i’ll practice more when i get more time)

and even then, I reviewed the playermodule and I laughed because how unreadbable and bad it is. I’m sure that if you just give the entire thing to an AI it would throw you up a much better version than this mess

1 Like