So I’m trying to override the default character reset behavior using StarterGui:SetCore("ResetButtonCallback", BindableEvent) so I can run custom logic before allowing a reset. The goal is to block resetting while the player is in combat by checking the "InCombat" attribute on the character. If they are in combat, it should notify them and cancel the reset.
Here’s my LocalScript code:
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local ResetBindable = Instance.new("BindableEvent")
local function HandleReset()
if Character and Character:GetAttribute("InCombat") then
StarterGui:SetCore("SendNotification", {
Title = "NOTIFICATION",
Text = "WAIT 10 SECONDS BEFORE RESPAWNING",
Duration = 5
})
return
end
end
ResetBindable.Event:Connect(HandleReset)
local function SetupResetCallback()
local Success, Error = pcall(function()
StarterGui:SetCore("ResetButtonCallback", ResetBindable)
end)
if not Success then
warn("Reset callback setup failed:", Error)
task.delay(1, SetupResetCallback)
end
end
The Issue
The custom reset logic isn’t being triggered at all, and the default reset behavior still happens like the callback was never applied. I’ve added debug prints, and while the script itself runs, HandleReset never fires. I also tried wrapping the SetCore("ResetButtonCallback", ...) call in a pcall with a retry delay, but even then, it doesn’t print whether it was successful or not, and the callback still doesn’t work.
When I remove the pcall, I get the following error:
ResetButtonCallback is not a valid member of SetCore
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character
function ResetInCombat()
local Attribute = Character:GetAttribute("InCombat")
warn(Attribute)
if Attribute == true then
StarterGui:SetCore("ResetButtonCallback", false)
warn("custom event oncombat")
else
StarterGui:SetCore("ResetButtonCallback", true)
warn("custom event non oncombat")
end
end
ResetInCombat()
Character:GetAttributeChangedSignal("InCombat"):Connect(ResetInCombat)
I don’t need help handling the attribute; I already manage that in my other combat systems. My only issue here is that the callback isn’t being assigned correctly and throws an error. Resetting doesn’t prevent the player from dying; in fact, it doesn’t seem to do anything at all. The reset button behaves like normal, and the HandleReset function never gets triggered. It’s as if the callback isn’t connected at all.
I’ve wrapped SetCore("ResetButtonCallback", ...) in a pcall with a retry delay, but it doesn’t print whether it was successful or not, and the behavior remains unchanged. When I remove the pcall, I get the error I mentioned above.
I’m honestly shocked by how many people saw the post and couldn’t help.
Apparently, I forgot to call SetupResetCallback(), so that’s why it wasn’t working. I apologize for that; I was coding literally at 3 AM in my time zone.
Here’s the full code, and it should work fine now. Anyone who wants to use it in their game, feel free.
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local ResetBindable = Instance.new("BindableEvent")
local function HandleReset()
if Character and Character:GetAttribute("InCombat") then
StarterGui:SetCore("SendNotification", {
Title = "NOTIFICATION",
Text = "WAIT 10 SECONDS BEFORE RESPAWNING",
Duration = 5
})
return
end
end
ResetBindable.Event:Connect(HandleReset)
local function SetupResetCallback()
local Success, Error = pcall(function()
StarterGui:SetCore("ResetButtonCallback", ResetBindable)
end)
if not Success then
warn("Reset callback setup failed:", Error)
task.delay(1, SetupResetCallback)
end
end
SetupResetCallback()