I cannot figure out how to successfully guarantee the core gui is removed.
ReplicatedFirst.Loading:39: SetCore: ResetButtonCallback has not been registered by the CoreScripts
I mean, I can keep adding retries, but it shouldn’t take 8 tries in the first place
local CoreCall do
local MAX_RETRIES = 8
local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui")
function CoreCall(method, ...)
local Result = {}
for retries = 1, MAX_RETRIES do
Result = {pcall(StarterGui[method], StarterGui, ...)}
if Result[1] then break end
task.wait(0.5)
end
return unpack(Result)
end
end
assert(CoreCall("SetCore", "ResetButtonCallback", false))
while not Success do
Success = pcall(function()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
end)
task.wait(1)
end
function coreCall(method, ...)
local MAX_ATTEMPTS = 5
local attemptCount = 0
local fired, result
repeat
fired, result = pcall(StarterGui[method], StarterGui, ...)
attemptCount += 1
task.wait(1)
until fired or attemptCount > MAX_ATTEMPTS
end
It’s simple: While this error is unavioudable, there are some fixes to it.
You can make a loop to register it, such as this:
repeat
task.wait()
until game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
Alternatively, you could just teleport the player to a new server instance if it’s not registered. These are the two most efficient ways to do it which I found. Anyway, cheers!
The error in the OP is specific to SetCore. SetCoreGuiEnabled does not produce this error because they accept initial state from scripts as well as configuration later during run time. Even then, you should not be using a repeat loop here because your code may end up waiting one iteration unnecessarily if it’s already able to be executed immediately.
Registration occurs as CoreScripts are executed and set up the backend for the relevant option. Teleporting players to a new server has no bearing on registration and is a poor non-solution.