Disabling the Reset Character button

Hi fellow developers! Sorry if the creation of this topic is not necessary but I’ve been trying to figure this out for awhile now - but to no avail. I stumbled upon this code a few times in the DevForum (sorry if not credited I am not sure who wrote the original code and I do not want to credit the wrong person):

local coreCall do
	local MAX_RETRIES = 8

	local StarterGui = game:GetService('StarterGui')
	local RunService = game:GetService('RunService')

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

It works well, and the Reset Character button is disabled. I understand how Variadic functions work and all, but I do not understand the rest of the code. If anybody could kindly explain the reasoning behind this I would greatly appreciate it. I do not understand why it is looped exactly 8 times and why the loop should be broken if ‘result’ with index 1 is true. Thank you!


I’ll try my best to explain.

After researching, I found out about it in this post:

If you’ve used SetCore before you may have seen the ‘ has not been registed by the CoreScripts’, this is because the SetCores take time to be initialized therefore you’ll need to pcall it and keep trying.

Here’s a small example:

local success
while not success do
   success = pcall(sg.SetCore, sg, "TopbarEnabled", false)
   wait(1) --add a wait to ensure no Game script timeouts :P

As for the function, this is because pcall returns two values: the first one is a bool, whether the function was a success or not. The second is the response: if the first value was a success and you did return in pcall, the response will be the returned value. If it errors, aka success is false, it returns the error message.


Thank you so much for taking the time to explain! Does that mean that I could loop it possibly less or more than 8 times, and 8 is just a safe number to use?

1 Like

I believe 8 is enough, but you can increase. I am not sure what the limit to it though.