From one update to the next, ResetOnSpawn is no longer being honored. I have elements that are set to false, and I have scripts for my TopBarPlus and other elements that rely on grabbing the initial screen gui, then wiring into static or dynamically created elements. However on reset, those screengui are recreated or something is happening, and the buttons no longer work.
Here is a code example that worked flawlessly prior to one of the most recent updates
--
--
--
-- Setup
local ICON_BUTTON = 105512384542974
-- Services
local player = game:GetService( "Players" ).LocalPlayer
local collection_service = game:GetService( "CollectionService" )
local replicated_storage = game:GetService( "ReplicatedStorage" )
-- TopBarPlus
local container = replicated_storage.Modules.TopbarPlus
local icon = require( container.Icon )
-- Acecool
local Acecool = replicated_storage:WaitForChild( "Acecool" )
local gui_manager = require( Acecool.Modules.GuiManager )
local lib = require( script.Parent.lib_topbar )
--
--
--
local gui = player.PlayerGui:WaitForChild( "TopBar", 60 ):WaitForChild( "GuiGamePasses", 60 )
local frame = gui:WaitForChild( "Frame" )
--
--
--
local menu = icon.new( )
:setName( "SettingsMenu" )
:align( "Right" )
:setOrder( 200 )
lib:ApplyUIStroke( menu.widget )
--
-- Settings
--
local button = icon.new( )
:setName( "GamePassesButton" )
:setImage( ICON_BUTTON, "Deselected" )
:align( "Right" )
:oneClick( true )
:setImageScale( 1, "Deselected" )
:setOrder( 1 )
--
-- Setup the menu
--
menu:setFixedMenu( {
button,
} )
collection_service:AddTag( button.widget, "GuiMouseOnHover" )
--
-- Monitor frame visibility changes
--
frame:GetPropertyChangedSignal( "Visible" ):Connect( function( )
-- Rotate button based on visibility
lib:RotateButton( button, frame.Visible and 90 or 0 )
-- Play a sound and close all other Primary Gui on open
if ( frame.Visible ) then
lib:PlaySound( "MENU_OPEN" )
gui_manager.CloseAllExcept( frame )
end
end )
--
-- Toggle button
--
button:bindEvent( "deselected", function( self )
frame.Visible = not frame.Visible
end )
That works exactly as intended before death. On death, even though the ScreenGui is has ResetOnSpawn to false, it resets which breaks the “frame” reference. A quick test, in bindEvent re-reading frame fixes that, but that requires additional logic to disconnect, and connect the listeners each time which I am fine with doing but this bug still exists.
Expected behavior
I expect ResetOnSpawn to be honored so the scripts that rely on keeping a reference to a ScreenGui don’t break on death.
Here is an example - It worked like this before, even after death. But now with the update, after death you see it doesn’t work. I added a quick variable in frame.Visible = not frame.Visible to refetch frame and that is why the right middle button shows, but the animation doesn’t. Because those variables are being lost.
