LayerCollector.ResetOnSpawn not respected when LayerCollecter's immediate parent is not StarterGui

I came across a problem when I was trying to use the ResetOnSpawn property for some ScreenGui’s, which were descendants of StarterGui

However, if you do not put them immediately into StarterGui, ResetOnSpawn is not respected, and the UI is recreated when a player is respawned.

Steps to Reproduce:

  • Create a folder inside StarterGui
  • Create a ScreenGui and set ResetOnSpawn to false
  • Add a LocalScript inside this StarterGui with a simple print inside
  • Go in game, and then check Developer Console. There will be a print.
  • Reset your character
  • The text will be printed again
8 Likes

This has started happening in the live version of Bee Swarm Sim, except it also affects scripts that are immediately in StarterGui. A LocalScript in StarterGui that’s responsible for setting up the GUI/Menus will run again every time the character respawns, causing duplicates of elements and generally breaking the menu system. This doesn’t happen in studio, however. Not sure how to go about fixing it but it’s pretty game breaking.

Edit: I also think it may be re-initiating module scripts in ReplicatedStorage. I tried to prevent it from re-running scripts by checking for a flag stored in a ReplicatedStorage module script and it doesn’t seem to save.

I’ve checked a few other games and the only other one that seemed to be affected was Super Power Training Simulator. If you respawn, none of the buttons on screen work and you can no longer open the menu (similar to Bee Swarm Sim).

4 Likes

I can confirm this, we haven’t made any changes to our game recently.

Should this be [Roblox Critical] ?

2 Likes

Looking into a possible cause for this. Do you have simple reproduction for this?

You can take a look at this

Seems like he found out why, I don’t really know the cause, but try playing my game.

If you put a LocalScript in StarterGui that prints a message, it will print it every time you respawn in the release version (not in studio).

If you put a LocalScript into a ScreenGui within the StarterGui, it will print the message twice upon entering the game, as if it’s ran twice (also not replicated in studio). This happens regardless of if the ScreenGui has ResetOnSpawn enabled or not.

Edit: The second problem is only happening with some LocalScripts and not others, trying to figure out the difference…

4 Likes

The script always printed every time (and it also prints every time in studio). I think this is the expected behavior if StarterGui.ResetPlayerGuiOnSpawn.

If you have an rbxl file that reproduces the second issue can you post it on the thread or DM it to me?

Oh! I was setting StarterGui.ResetPlayerGuiOnSpawn to false in a LocalScript in the StarterGui (it’s been that way since the release of the game). My guess is it was working for so long just accidentally and a change behind the scenes has caused it to stop. Setting it to false directly in studio direct fixes the problem. Thank you!

3 Likes

Wait a second, so are you saying that toggling ResetOnSpawn’s value fixes the issue?

My game has ResetOnSpawn = false it was set by hand and not a script.

@Unbunn_makes is also having a problem, he’ll be happy for a solution, as well as everyone else.

So the change that was made that causes the issue in bee swarm simulator is now the PlayerGui is reset on the server, not the client. Because of this change setting StarterGui.ResetPlayerGuiOnSpawn to false in a LocalScript no longer stops the PlayerGui from being reset when the character spawns.

It looks like the issue in your game is probably caused by the same change but is a bit different. We should be able to try turning off this change to see if it fixes the issue when people in the office wake up.

2 Likes

It’s a different property from ResetOnSpawn - in my case I was setting StarterGui.ResetPlayerGuiOnSpawn to false in a LocalScript, and it seems like that doesn’t work anymore. Using a server script or just with the command line in Studio (it’s not exposed as a tick box) fixes it though.

3 Likes

@TheGamer101, @Onett

̶S̶o̶ ̶i̶t̶ ̶o̶n̶l̶y̶ ̶e̶f̶f̶e̶c̶t̶s̶ ̶S̶c̶r̶i̶p̶t̶s̶ ̶b̶u̶t̶ ̶n̶o̶t̶h̶i̶n̶g̶ ̶e̶l̶s̶e̶?

̶I̶n̶ ̶t̶h̶i̶s̶ ̶c̶a̶s̶e̶ ̶a̶n̶ ̶e̶a̶s̶y̶ ̶f̶i̶x̶ ̶w̶o̶u̶l̶d̶ ̶b̶e̶ ̶t̶o̶ ̶P̶a̶r̶e̶n̶t̶ ̶t̶h̶e̶ ̶L̶o̶c̶a̶l̶S̶c̶r̶i̶p̶t̶ ̶e̶l̶s̶e̶w̶h̶e̶r̶e̶.

https://gyazo.com/d97f19ae1cf0b70b7ae509b292f0a92b

The Gui Duplicates for some reason, so the script is still running, the old UI is still there but the new UI’s button is blocking input to the old one causing it to not fire MouseButton1Down event


Still happens after I ran this in the command bar

game.StarterGui.ResetPlayerGuiOnSpawn = false

so I had to check

image

I’m not sure exactly why the behaviour is different from what happened previously but what is happening seems to be that you have a script in ReplciatedFirst that copies these two ScreenGuis from StarterGui to PlayerGui. Then when your character is spawned the PlayerGui is not reset and these are still copied over.

A way you can fix this temporarily in your game is to instead copy these GUIs from ReplicatedStorage to PlayerGui and remove them from StarterGui.

Actually it parents those two ScreenGuis from StarterGui to PlayerGui.

local IntroGui = game:GetService("StarterGui"):WaitForChild("IntroGui")

IntroGui.Enabled = false

IntroGui.Parent = player:WaitForChild("PlayerGui")

local ScreenGui = game:GetService("StarterGui"):WaitForChild("ScreenGui")

ScreenGui.Enabled = false

ScreenGui.Parent = player:WaitForChild("PlayerGui")

How do I prevent this image mess ?


Do you have any intel of the Staffs that are responsible for this?

Ah I see, I wasn’t fully sure what exactly your game was doing. This makes sense, since PlayerGui is now copied over on the server the ScreenGuis will still be copied over (they are still in StarterGui on the server).

I have forwarded this thread on to the engineer responsible for this feature.

2 Likes

Hi @RuizuKun_Dev,

Do you get another duplicate as your character respawns a second time? Also what do you use as a trigger to copy in the above localscript to reparent the 2 guis to the PlayerGui?

Hi,

No, it happens the first time, I used Player.CharacterAdded to check if it fires twice but it only printed once, and after I reset it doesn’t create more duplicated GUIs

Nothing, it runs as soon as it can, this script is inside ReplciatedFirst

Thanks!

Yes, as TheGamer101 mentioned, the Guis are loaded because they are now copied on the server then replicated to the client instead of copying from the local client copy. And since the parent action happened on the client, the server’s copy is still existent because this reparent action is not replicated back to the server; therefore creating that second copy. (Please note that ResetOnSpawn is effective on respawn and not the initial spawn).

If you place these GUIs in ReplicatedStorage then reparent them to the playerGui, this should stop that from being duplicated.

1 Like

I’ll do that right away. Thank you!

Edit: Seems like it’s fixed! :clap:


Why is this a problem now and not before what changed?

This?

Why did Roblox decided to make this change?


@Unbunn_makes is also having an issue, I’m unsure of the details but I doubt that he’ll have the same solution as mine.