StarterGui:SetCore()

The code:

if script.Parent.load.Frame.Visible == true then
    game.StarterGui:SetCore("TopBarEnabled",false);
end;

The error


  SetCore: TopBarEnabled has not been registered by the CoreScripts

I tried to also add a wait but that didn’t work

1 Like

It’s TopbarEnabled, not TopBarEnabled.

1 Like

ohhhh thanks! so much I why is the error so irrelevant though?

It’s because it is case sensitive.

How would I check if the topbar is enabled

game.StarterGui:GetCore("TopbarEnabled");

Another thing to note is that SetCore can fail, so you should always wrap in in a pcall and retry if it does.

local StarterGui = game:GetService("StarterGui")

if script.Parent.load.Frame.Visible == true then
    local success, message = pcall(StarterGui.SetCore, StarterGui, "TopbarEnabled", false)
    while not success do
        game:GetService("RunService").Stepped:Wait()
        success, message = pcall(StarterGui.SetCore, StarterGui, "TopbarEnabled", false)
    end
end

It’s case sensitive, the error means it hasn’t been registered by core scripts, which is because TopBarEnabled doesn’t exist.

1 Like

I am bad at coding so idk what pcall is :smile:

In simple terms, it prevents an error from stopping the rest of the script from running and gives a reason for the error.

pcall is short for protected call, which means functions executed inside it won’t stop script execution if they error. If they do error, you also get the error message back which can be helpful when dealing with stuff like Datastores. Here’s the wiki page, and an article about it.

1 Like

oh okay, I will have to look into this though!