ScreenGui doesn't seem to go away when I set Enabled = false

I might be dumb in some way, but for some reason, my ScreenGui doesn’t disable when I change the Enabled property to false, even tho it changes when I set it to true in the other remote event. The EndMatch remote event does fire and connect.

Explorer:
Screenshot_714

Local Script called GUI Script:

local Players = game:GetService("Players")

--UI Variables
local GUI = script.Parent.Parent
local MainFrame = GUI:WaitForChild("MainFrame")
local BoardFrame = MainFrame:WaitForChild("BoardFrame")
local Spaces = BoardFrame.Spaces
local Title = MainFrame.Title
local Turn = MainFrame.Turn

--Remote Events
local BoardSpacePressed = game:GetService("ReplicatedStorage").BoardSpacePressed
local StartMatch = game:GetService("ReplicatedStorage").StartMatch
local EndMatch = game:GetService("ReplicatedStorage").EndMatch

local function ChangeTurn(isMyTurn)
	if isMyTurn then
		Turn.Text = "Your Turn!"
	else
		Turn.Text = "Opponent's Turn!"
	end
end

StartMatch.OnClientEvent:Connect(function(isMyTurn)
	GUI.Enabled = true --works
	ChangeTurn(isMyTurn)
end)


EndMatch.OnClientEvent:Connect(function()
	GUI.Enabled = false --doesn't work
	print("disabled") -- this does print in the output
end)
3 Likes

Are you firing the StartMatch event right after you call the EndMatch event?

4 Likes

I have a 3 second wait between firing the 2 events (events are fired in the self:Start() and self:End() functions) in my module script

function Board:Init()
	while true  do
		self:SetupMatch()

		self:Start()
		task.wait(3)
		self:End()
	end
end
1 Like

@DominoDominykas said it does print though. Meaning the event is being triggered.

2 Likes

It does print


the print(“worked”) comes from the serverside remote event :End() function:

Code block from the Module script that controls the remote events

function Board:End(player)
	for _, player in ipairs(self.Players) do
		EndMatch:FireClient(player)
		print("worked")
	end
end
2 Likes

I read that wrong, thanks for pointing that out :sweat_smile:

@DominoDominykas Yeah I’m stumped. Here is some diagnostic code to check a few of the things that might be happening:

-- Check if it's something is setting it back to Enabled
print("GUI.Enabled is ".. (if GUI.Enabled then "True" else "False")) -- Luau wins for the weirdest ternary operators
-- Check if it's the wrong copy (Maybe the one in StarterGUI? It shouldn't be.)
local Players = game:GetService("Players")
if not GUI:IsDescendantOf(Players.LocalPlayer) then
    print("Wrong copy! GUI is not inside PlayerGUI.")
end
-- Check if there are duplicate GUIs (again, there shouldn't be based on the setup)
local copies = 0
for _, child in ipairs(Players.LocalPlayer.PlayerGui:GetChildren()) do
    if child.Name == GUI.name then
        copies += 1
    end
end
print("There are "..copies.." copies in PlayerGui")

Truly stumped on why this is though, it seems like it shouldn’t be from any of these cases.

(The code goes after the GUI.Enabled = false --doesn't work line)

Edit:

Hopefully fixed!

Hopefully fixed x2 (my Luau is a little rusty).

2 Likes

I can not see anything that looks like it shouldn’t be working.
Have you tried disabling it in the workspace while the game is running?
Are there any other scripts that might enable it somehow?

2 Likes

Now it seems to not even show at all while in testing, even when its enabled in the properties. When I disable it manually thru the properties, it seems to enable itself (doesn’t show anything), but not disable it.

I only have 3 scripts in the game which are the: Local script, Module script, and the server script in serverscriptservice that just runs the module script.

Here’s the ScreenGui’s properties:

1 Like


error in the output

2 Likes

try saying:
print("GUI.Enabled is " .. tostring(GUI.Enabled))

2 Likes


another error, but on line 42

2 Likes

Fixed that one too in the original code :sweat_smile:

2 Likes

2 Likes

That returned everything as it should lol.
Can you send a video of what is happening when you play test?

2 Likes

sure, wait a little bit (like 15 minutes) because my internet upload speed is pretty slow + I’ll have to send thru youtube since devforums for some reason errors and wont let me send a video straight thru a reply

2 Likes

Is your GUI inside the StarterGui and has ResetOnSpawn set to true? If so then you may have set the .Enabled property of that UI to true, which means that if a player resets after your GUI.Enabled = false statement your GUI will appear again.

2 Likes

Video of the issue:

I fixed this, I forgot to reenable Visible = True on MainFrame, but the issue of the GUI not dissapearing still persists

1 Like

Are you able to provide a place file so I can try and replicate this issue on my side?

2 Likes

same issue even when I disable it.

1 Like

Tic Tac Toe Remake.rbxl (67.1 KB)

2 Likes