SetCoreGuiEnabled only works once?

I’ve noticed in one of my games that the script I use to control the CoreGUI randomly stopped working. No changes have been made to the code for months. I tried making a new project with the same code and as a result, I can only disable and enable the CoreGUI once, and then it no longer works.

local UIS = game:GetService("UserInputService")
local StarterGUI = game:GetService("StarterGui")
local mouse = game.Players.LocalPlayer:GetMouse()

function change(action)
	if action == "Hide" then
		UIS.MouseIconEnabled = false
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)
	end
	if action == "Show" then
		UIS.MouseIconEnabled = true
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, true)
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
	end
end

game.ReplicatedStorage.Remotes.ChangeUI.OnClientEvent:Connect(function(action)
	change(action)
end)

A server script enables and disables it over and over in a loop, however it only ends up actually doing it for one iteration. I know for certain it is reaching that portion of the code. I have no idea why this would randomly stop working, I was formerly having no issues with enabling/disabling CoreGUI in my game ;-;

Does anyone know what could be causing this, what I may be doing wrong, or can confirm that they are experiencing the same issue?

3 Likes

Where is it getting fired from?

1 Like

I’ve tried it firing a remote event from the server as well as a bindable event on the client.

Both yield the same result

1 Like

Can you show me the script where it is being fired from…

I’m not exactly sure why yours is not working correctly but, from my testing it seems that it does infact work more than once.

local startergui = game:GetService('StarterGui')

local bool = false
while task.wait(1) do
	startergui:SetCoreGuiEnabled('All',bool)
	bool = not bool
end

Mayby try changing your function to something like this:

local function change(action)
	if action == "Hide" then
		UIS.MouseIconEnabled = false
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.All,false)
	else
		UIS.MouseIconEnabled = true
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, true)
		StarterGUI:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
	end
end

I need to be able to do this with a remote event and bindable event, have you tried those?

1 Like

That information is not necessary as I already specified in the original post that it was reaching that section of the code. You can have it anyways if you want, this is a script in ServerScriptService.

I’ve also tried adding print statements and they properly display in the output, however the leaderboard and chat are only being enabled and disabled a single time.


Hm, this is odd. I’m having the same issue, I’ll try to see if I can make a workaround.

This seems to work for me, let me know if you have any issues with it.

local event = game:GetService('ReplicatedStorage').uievent
local startergui = game:GetService('StarterGui')

local function coreenable(action)
	startergui:SetCoreGuiEnabled('All',action)
end

event.OnClientEvent:Connect(function(value)
	coreenable(value)
end)

This does seem to work, but when I try changing it to only enable the Chat, Playerlist and EmotesMenu it fails.

This should work.

local startergui = game:GetService('StarterGui')
local event = game:GetService('ReplicatedStorage').RemoteEvent

local function updatecore(action)
	if action then
		startergui:SetCoreGuiEnabled('All',true)
	else
		startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,false)
		startergui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu,false)
		startergui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
	end
end

event.OnClientEvent:Connect(updatecore)
while task.wait(1) do
	game:GetService('ReplicatedStorage').RemoteEvent:FireAllClients(true)
	task.wait(1)
	game:GetService('ReplicatedStorage').RemoteEvent:FireAllClients(false)
end

My intention was for the Backpack and Health to remain hidden, while (Chat/Emotes/PlayerList) can be toggled off and on.

Thank you for the help, I managed to fix it like this:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)

function change(action)
	if action == "Hide" then
		UIS.MouseIconEnabled = false
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
	end
	if action == "Show" then
		UIS.MouseIconEnabled = true
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, true)
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
	end
end

I’m not sure why but using “All” with false seemed to stop working after enabling the other’s individually.

1 Like

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