Setting Core GUI to disabled works sometimes but not always

Hello! So, I’ve made a script that sets the reset button and the topbar to disabled for a certain amount of time, and then sets them back to enabled. For some reason, the script works sometimes, but throws this error other times:


The times it works and the time it doesn’t work are completely random. My script is currently this:

local StarterGui = game:GetService("StarterGui")

StarterGui:SetCore("TopbarEnabled",false)
StarterGui:SetCore("ResetButtonCallback", false)

local fin = script.Parent.Handler.Finished

fin.Changed:Connect(function()
	if fin.Value == true then
		StarterGui:SetCore("TopbarEnabled",true)
		StarterGui:SetCore("ResetButtonCallback", true)
	end
end)

This is in a LocalScript inside a Screen GUI.

Does anyone know why this is happening?

1 Like

They’re not random. The error is saying the corescripts haven’t setup the property for ResetButtonCallback. The core scripts execute after your localscripts.

2 Likes

Oh ok, then I have two questions. First, why does it work sometimes and not always? Second, if this is a problem, how would I fix it? Thanks!

I think this could help, you can look at the other posts for a better understanding why but @InfinityDesign pretty much summed it up

1 Like

Oh, thanks a lot! I’ll try that script to see if it works!

Enabling and disabling the resetbuttoncallback is really not recommended, as you are messing with core scripts that can potentially have performance repercussions within your games. Also, note that local scripts run only after core scripts, so it’s normal if it doesn’t work from time to time.

1 Like

Thank you for your response! I will try my best to make little use of this, but as of right now, I need to enable and disable the reset button as it’s a necessary part of my game.

1 Like

Theres no performance overhead from disabiling resets. You can lose players if the game allows them to get stuck anywhere they’d try to reset to get out of but theres no other cons to disabiling them.

The LocalScripts execute a great deal sooner than the CoreScripts, which is what’s causing this problem. This is a common occurence with properties the corescripts assign to after initalizing, such as CameraType, MouseIcon, and Focus.

1 Like