:SetCore("TobarEnabled") throws an error without a wait()

--wait()
game.StarterGui:SetCore("TopbarEnabled", false)

Leave the wait commented:

SetCore: TopbarEnabled has not been registered by the CoreScripts

Uncomment the wait, no error.
Am I the only one having this problem? (My brother did as well).

2 Likes

Core scripts aren’t guaranteed to run before your own localscripts. This is the correct behavior.
Best strategy:

-- Disable the topbar asap
coroutine.wrap(function()
    local timeout = 1
    local t = tick()
    while not pcall(game.StarterGui.SetCore, game.StarterGui, "TopbarEnabled", false) and tick()-t<timeout do
        wait()
    end
end)()

Edit: added timeout, new thread

4 Likes

What if they disable the flag, so it’ll never work?

do local time = tick()
    repeat
        wait()
    until tick() - time >= 1 or pcall(game.StarterGui.SetCore, game.StarterGui, "TopbarEnabled", false)
end

Hence why the announcement thread said to add a wait and a pcall.

Not replying to a specific person.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.