Custom reset logic will not run when the player resets themself

  1. What do you want to achieve? Trying to make a custom reset system.

  2. What is the issue? The problem is that the code never runs.

  3. What solutions have you tried so far? Try changing the code some bit and the code still will not run when the player resets.

I just want this code to work because this is suppose to fire when the player resets.

-- Local script
local player = game.Players.LocalPlayer

local resetBindable = Instance.new("BindableEvent")
resetBindable.Event:connect(function()
	-- Implement custom reset logic here
	
    -- It never prints lol and no errors at all
	print("Lol")
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", true)

Is the script disabled? Have you tried a printline at the top?

1 Like

I check the output and there was no errors, and the script is enabled.

1 Like

Are you 100% sure the script itself is getting called? Where is it located?

1 Like

In game.Players.SR02justin.PlayerGui.UI.TeamFrame.Event.Script.LocalScript
Event is a Remote event where Script is a ServerScript

1 Like

Put print(“Local script called”) as the very first line and run it

1 Like

Why are you setting the reset button callback back to true like it is by default? Try removing that line and see if it works.

2 Likes

I did that and it printed that but I still don’t see it print lol when I reset.

Then the problem is your logic that connects the function

1 Like

The what if preventing it from working it never even errors?

It never even prints lol even after removing that part of code

SetCore: ResetButtonCallback has not been registered by the CoreScripts

1 Like

It never even gives a error message like that

1 Like

Try waiting a bit before setting the callback.

Im using the exact code as you, but I changed it to a non-anonymous function

1 Like

How do I do that? I don’t know how.

1 Like

– Local script

print(“local called”)

local player = game.Players.LocalPlayer

local resetBindable = Instance.new(“BindableEvent”)

local function onReset()

print(“onReset called”)

end

resetBindable.Event:connect(onReset)

– 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”, true)

–resetBindable.Event:connect(onReset)

2 Likes

Oh so you just connect a local function. I know about local functions I use them a lot in my games just didn’t know that the old code was that broken. Thanks!

1 Like