Reset Button Callback Not Working Everytime

Hello everyone,

I am using a custom health system. I am trying to override the reset button so I can set my own health to 0. Generally, it works. But once in awhile, this will not work and when you press reset it will reset you with the Roblox default system. This probably happens 1/15 times. Obviously, this system can not work if this happens rarely. Here is the code I am using.

 local coreCall do
	local MAX_RETRIES = 8

	function coreCall(method, ...)
		local result = {}
		for retries = 1, MAX_RETRIES do
			result = {pcall(StarterGui[method], StarterGui, ...)}
			if result[1] then
		return unpack(result)

assert(coreCall('SetCore', 'ResetButtonCallback', remotes.resetBind))

What could I do to make this work every time and why is it not?

Increase the value of the MAX_RETRIES constant.

You may also need to swap RunService.Stepped:Wait() for task.wait(0.1) or some other longer yield duration.

if you want more reliable code, this should work, although it reads worse
I would’ve just yielded until resetbuttoncallback was registered in getcore but it never registers so yeah

local starterGui = game:GetService("StarterGui")
if not game:IsLoaded() then

repeat task.wait() until pcall(starterGui.SetCore,starterGui,"ResetButtonCallback",false)