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)
-- 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.
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.
-- 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.
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
â âŚ