I’m having trouble with disabling and enabling the core gui for a menu I’m making. I’ve tried debugging it but for whatever reason the gui will not change states even if it has in the code
This is my code snippet
local function activatePlayerGui(bool)
print( not bool)
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All,not bool)
print(startergui:GetCoreGuiEnabled(Enum.CoreGuiType.All))
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end
When this is called it runs through just fine but the core gui is still enabled. I added the print statements to see what was going on and an expected output would look like this:
Output:
false
true
Instead the output I get is this:
Output:
false
false
This is despite the fact that the actual gui is still visible.
Solutions I’ve tried
I’ve tried the trick where you repeat the action over and over until the gui has been enabled, but this doesn’t work as the bool showing whether or not the gui is activated isn’t accurate to the actual state of the gui.
I did try removing the backpack false bit at the bottom, it made no difference.
I’ve looked in my other scripts, there is not other use of setcoreguienabled
I’ve tried each element individually, it didn’t make a difference.
I’ve tried looking to other posts on the devforum, they haven’t been much help from what I have found.
The local script is under a folder within a ScreenGui for a settings menu I’m making.
I’m confused on how would the expected output be different. You’re printing not bool, then setting the CoreGuiEnabled to that value. This would mean that the value printed for not bool is the second parameter for SetCoreGuiEnabled.
If it prints not bool = false, then startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All,not bool) will set it to false. Your output should be the expected behavior, as you’re printing the opposite of bool and then setting the core gui enabled to that. I’d try removing the not if you’d expect the output to be different.
In my code I had the backpack core gui being disabled and for whatever reason if one of the coregui’s are disabled or not in their default state setting all to false doesnt work. Thanks everyone for your help.