I have a LocalScript that prevents the player from resetting. It only works half the time

Sometimes it will work and sometimes it’ll just break. I’m trying to figure out why. This was pulled straight from the wiki with a few modifications:

local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

StarterGui:SetCore("ResetButtonCallback", false) --Sometimes breaks here.

Again, this does work sometimes but at other times it doesn’t. What am I missing here?

I had an issue like this once. When you get that error you may just have to keep trying until it works.

local StarterGui = game:GetService("StarterGui")

local attempts = 5
local retryTime = 1
local success = false
while (not success and attempts > 0) do
	success = pcall(StarterGui.SetCore, StarterGui, "ResetButtonCallBack", false)
	attempts -= 1
	wait(retryTime)
end
if (success) then
	print("Disabled the reset button.")
else
	warn("Could not disable the reset button.")
end

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- rest of script
2 Likes