I have this function (in a module script) which seems to work perfectly in studio but in an actual game the coregui can be disabled through this function but whenever I try enable it again it does not work
function UiUtil.SetCoreUi(enabled : boolean)
spawn(function()
local timeout = 5
local t = tick()
local success, err = pcall(function()
StarterGui:SetCoreGuiEnabled('All', false)
if enabled then
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
end
end)
while not success and tick() - t < timeout do
task.wait()
end
end)
end
Also if you disable all of coregui it will disable everything until you set it to be enabled again so you would need to set all the other cores to be false instead
No errors are printed. Even when I do the following (constantly trying to enable the core gui) it is not enabled while playing in game although works fine in studio.
while true do
task.wait(1)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
end
Why are you looping over it if it isn’t a success? It will return if it’s a success or not so if it isn’t just call the function again instead of a while loop
You need a pcall incase you call SetCoreGui before the core gui is loaded. And the spawn just makes it so I dont have to wait for the core gui to load while doing other stuff.
ive fixed it. There was another script that disabled the core GUI when the game starts and somehow that effected my script which doesnt really make sense.