How to check when player resets

idk how to check when player resets and not dies, i found this online but it doesnt work as i get an error of this:

SetCore: ResetButtonCallback has not been registered by the CoreScripts

this is the part i found online:

local resetBindable = Instance.new("BindableEvent")
resetBindable.Event:connect(function()
    -- Implement custom reset logic here
end)

-- This will remove the current behavior for when the reset button 
-- is pressed and just fire resetBindable instead.
game:GetService("StarterGui"):SetCore("ResetButtonCallback", resetBindable)

-- Setting ResetButtonCallback to false will grey out the reset button
-- in the menu and players won't be able to reset in your game.
game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
1 Like

Unfortunately you need to call them in a pcall. Roblox often errors ‘SetCore()’ calls seemingly at random.

Here’s more info: ResetButtonCallback has not been registered by the CoreScripts

-- Since Roblox doesn’t immediately register these, you’ll have to wrap it in a pcall, like this:

local StarterGui = game:GetService("StarterGui")

local resetBindable = Instance.new("BindableEvent")
resetBindable.Event:Connect(function ()
    -- Implement custom reset logic here
end)

while true do
  local success = pcall(function () StarterGui:SetCore("ResetButtonCallback", resetBindable) end)
  if success then
    break
  else
    task.wait()
  end
end

-- The pcall means that an error won’t end the script, but will instead only return false, which you can then check for, wait for one frame, and then try again, until ResetButtonCallback is registered and the error no longer occurs.
-- It’s janky, but that’s the only official way we have of doing it right now, even according to the Roblox documentation.

the solution given in the other form u sent only disables the button

i get the error of break must be in a loop

If you still want it to kill the player, you’ll have to add logic for that.

There’s multiple ways to kill the client. humanoid.Health = 0 should work.

yes i want it to kill the player and send a remote event called “reset”

Add that to the event handler.
That logic will run once the player presses the reset button.
It’s an override, as in roblox won’t do anything for you.

-- My bad, I forgot a closing parenthesis. Try it now.

-- This is not good advice, what if it takes more than three seconds for the core scripts to initialize?

1 Like

-- They are not that expensive, you are just up and wrong. You don’t want to be wrapping your entire game in pcalls obviously, but one pcall per frame is not going to cause a performance hit, nor is it going to cause anything more than the most insanely negligible amount of memory usage that will immediately be freed up once the loop is complete. Please do not make things up in your head.

roblox approves that word? or is it just cuz its here

-- I wasn’t even being rude. It is legitimately harmful how much people make things up in this forum, it does the opposite of help people.

local StarterGui = game:GetService(“StarterGui”)
local Reset = Instance.new("BindableEvent")

Reset.Event:Connect(function()
    -- Implement custom reset logic here
end)

StarterGui:SetCore("ResetButtonCallback", Reset)

do
    local success

    repeat
        success = pcall(StarterGui.SetCore, StarterGui, “ResetButtonCallback”, false)
        task.wait()
    until 
        success
end

— …

What are you even supposed to do then?