As far as I can tell there has been a change to the way scripts are handled in PlayerGui, and it has made certain things impossible to do in Roblox, namely perpetual local scripts distributed during the game.
I have an animation script that runs some train wheels. When the train loads, it gives players a LocalScript that is custom for the set of train wheels. This script is for use in free models and is designed in such a way to require as little infrastructure as possible. To that end, it uses a server script to manage players receiving the LocalScript: any time a player joins, it gives them the LocalScript by placing it in their PlayerGui. The LocalScript initializes by wait()ing and then parenting itself to PlayerScripts, with the intention of preventing it from being deleted when the player resets. This is a change from several months ago where I had to change the server script from placing the LocalScript in the Backpack because a change to how Roblox works made it unusable.
Now, recently, I have discovered that placing it in PlayerGui is not viable either. At some point recently, these scripts started getting deleted when the player resets. I’m not sure of the exact time. I’ve asked the train community that uses the scripts the most and they told me they do recall the LocalScript persisting – even on games with
Since this change it’s now impossible for a server script to give a player a LocalScript for an arbitrarily long time period because PlayerScripts is not replicated. There’s simply no way for a server script to tell a client, “see this LocalScript? I want you to run it until the game closes or the train is deleted. Don’t stop running even when the character resets.”
There’s the possibility of making a bootstrapper LocalScript, which acts similarly (is copied into PlayerGui) but the LocalScript copies the LocalScript into PlayerScripts instead of the ServerScript, but this is extremely hacky and I don’t like it one bit. There’s got to be a better way.
Hundreds of users have used the script in hundreds more locomotives, and whatever the solution ends up being, I will have to inform them of the update and get them to update each script individually.
Here is an example of a model that uses this process. The relevant scritps are
Advanced Loco Animation and its child.
Expected behavior: local scripts placed in PlayerGui are not destroyed when character reloads
Observed behavior: local scripts placed in PlayerGui are destroyed when character reloads