Player Script Updater - Keep Player Module Forks Up To Date

Player Script Updater

Player Script Updater (Rbx PSU on Github) is a simple plugin that allows you to quickly grab and fork the latest versions of some player scripts (at the moment specifically the Player, Camera and Control modules) without having to go into Studio testing just to grab them. Outside of pure convenience, there are also occasionally times when the behavior between the Roblox Player client and Roblox Studio test mode behave differently due to slightly outdated Studio versions grabbing older versions of player scripts. Forking it solves this by by replacing inserted scripts with the newer ones.

The plugin is available here:

While the source code if preferred is available here:

Latest Update

I’m aware that dumping lots of updates sequentially like this isn’t best practice, I just happen to be on a roll while working on this since I’m inspired, and updates will be much slower as school is starting soon.

8/10/22

  • Add split viewing mode for difference prompt; old behavior (referred to as unified prompt) can be used via environment variable unifiedDiffPrompt.
  • Add option to check for updates on startup and mark scripts as outdated accordingly. This is on by default for fresh installs, but can be turned on/off with environment variable checkUpdates.

Miscellaneous fixes

  • Environment not updating when edited
  • Temporary files were archivable
  • Could start multiple update processes at once
Previous Updates

8/9/22

  • Added ability to change behavior via environment variables
  • Added an option to view the updated script in a script editor if using the ScriptEditorService beta and if the scriptEditorServiceBeta environment variable is set. Note that using this replaces the view differences widget.

8/8/22

  • Generalized PlayerScriptsLoader code to support any additional modules put into folder _Forked
  • Changed the menu’s TextLabels to TextBoxes to support copying to clipboard
  • Added a difference prompt that will pop up when updating modules to latest Roblox Client version, showing what insertions and removals will be applied and giving you an option to refuse to update. Requires ScriptEditorService beta access ScriptEditorService access no longer required with latest change.
  • Changed the plugin into a folder and offloaded some of the code into modules; this newer version can be grabbed locally via Rojo or using the command line; see here

Usage

To use it, simply load the scripts, either all of them or specific ones you want to grab via the menu, and generate a new PlayerScriptsLoader so that the game properly uses the forked scripts instead of the original ones. When the modules are unmodified, they should act identically to the Roblox client modules as long as they’re up to date. Developers should only expect to update the modules every once in a while (once every couple weeks at most).

Environment Variables

There are a couple of environment variables that can be used to change the plugin’s behavior. These variables can be accessed via the toolbar.

-- Default Environment
return {
    -- Whether or not to skip viewing differences on updated modules
    skipDifferencePrompt = false,

    -- Skip update check and ALWAYS replace forked module with one grabbed from Roblox Client Tracker
    alwaysUpdate = false,

    -- Use ServerScriptService to pull up a temporary script that displays the changes made
    -- instead of using the difference viewer widget
    -- Highlighting differences is unfortunately not supported,
    -- but changes made to the temporary script will be applied
    -- No effect if skipDifferencePrompt is true
    scriptEditorServiceBeta = false,

    -- Use the unified different viewer instead of the split viewer
    -- (Changes are all in one page instead of two)
    unifiedDiffPrompt = false,

    -- Check for updates when Studio starts up and mark old scripts as outdated
    checkUpdates = true
}

Other Info

How it works

In case you don’t want to delve into the source code yourself but are curious about how it works, when getting the updated modules essentially it grabs the latest modules from the Roblox Client Tracker via HttpService and creates the ModuleScripts if they don’t exist already in StarterPlayerScripts._Forked, else replacing the source with the raw strings grabbed from the repo.
The plugin additionally uses Github’s REST API for commits in order to track commit dates and check the current version of the module’s commit date vs the one grabbed from the repo. It should be kept in mind that, although developers shouldn’t be updating the scripts too often in the first place, you can get throttled if too many requests are sent, so keep that in mind if you have a tendency to over-check.

Why does this exist in the first place?

I created this tool because of a recent (as of August 2, 2022) update pushed to the Roblox scripts which entirely removed runtime access to the CameraModule if not forked. Up until recently you could bypass this via masking FFlags but they removed the check for FFlagUserRemoveTheCameraApi, rendering the module entirely inaccessible as it literally just returned an empty table (return {}). I find it strange that we’re promised and given a readily accessible API so that we don’t have to create custom solutions, only for the APIs to be completely blocked from developers unless we (lo’ and behold) create a custom solution.
You can see more of my comments on this in the forum post I initially made where I was confused about why the behavior had suddenly changed.

Images

image

image

image

Split view difference prompt

Unified difference prompt

9 Likes