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:
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)
@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)
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?
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.
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
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.