Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

SetCore: ResetButtonCallback has not been registered by the CoreScripts?

I'm trying to disable the reset button for my game.

The script I had was working perfectly, then I tested it again to make sure, and sure enough it worked perfectly again. But then I tried testing the game a third time and it didn't work. I got the error shown in the title.

I really don't know what's happening since the script was working perfectly fine until I tested it a third time. Here's my script:

local StarterGui = game:GetService("StarterGui")

StarterGui:SetCore("ResetButtonCallback", false)

1 answer

✓ Accepted answer

Core scripts are not guaranteed to be registered at the time you call the function, this is something similar with using WaitForChild on Instances.

You need to use pcall for this case, it's a function that runs given function with shield, which means if the function errors, it won't error but will return you the error message.

In your case i would create a loop to loop few times and try to disable the callback.

local StarterGui = game:GetService('StarterGui')

local function DIsableResetButton()
	local RetryDelay = 0.25
	
	local MaxTries = 8
	local Tries = 0
	
	while (true) do
		Tries += 1

		local Success, Response = pcall(
			StarterGui.SetCore,
			StarterGui,
			"ResetButtonCallback",
			false
		)
		
		if (Success) or (Tries >= MaxTries) then
			break
		end

		wait(RetryDelay)
	end
end

DisableResetButton()

In this case i made it loop 8 times, the delay between loops is 0.25 which means if all 8 tries fail, it will yield for 2 seconds total, if none fail it won't yield because of break, this keyword breaks the loop, in this case the while true loop, it will just stop it and won't finish current itteration. return can also be used, it will just stop the whole function and return given value or nil.

The reason you should be checking for total tries is because if roblox disables one of the features, the function will be repeating infinitely, in this case, it will do it for given amount of times.

i called pcall in this case with 4 arguments, the last 2 are the arguments that SetCore:ResetButtonCallback requires, the first one is the function to call and the second one is self, you should probably not worry about it but since you call SetCore with colon :, in this case you can't so you need to replace the colon somehow, in this case StarterGui since SetCore is function of it.

Success is whether the function succeeded and Response is the response from the function, if the function does not return anything, it's the error, in this case it is, if nothing errored, Response would be nil, else it will be the error so you can print it to debug stuff.

This discussion is preserved as it was. New answers, comments, and votes are closed.