ScreenGui.Enabled = false doesn't make the GUI disappear

  1. What do you want to achieve? Keep it simple and clear!

I’m working on a team-joining system for my game using textbuttons. I’ve got the whole team joining functions nailed down (clicking the buttons will join their respective teams), but the screengui will not disappear when I set the screengui.enabled to false.

The code works as such:
Upon entering the game, this screengui should appear, then, you click one of the three buttons, you join the respective team, and then the screengui is supposed to disappear. Note that I wrote it so that there can only be one Noob and Zombie player on their teams, I’m making a card game :slight_smile:. I tested; the code for that works.

  1. What is the issue? Include screenshots / videos if possible!


    Screenshot_16
    Note: sys_team_ui is in StarterGui

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried setting ResetOnSpawn of the Screen_Gui to false. That doesn’t work.

-- local scripts button_noob, button_zomb, button_spect (only difference is string name being fired)
local event = script.Parent.Parent.join_team_signal

script.Parent.Activated:Connect(function()
	print("sent noob join request")
	event:FireServer("Noob")
end)

-- server script sys_team
local sg = game:GetService("StarterGui")
local teams = game:GetService("Teams")
local event = script.Parent.join_team_signal

event.OnServerEvent:Connect(function(plr, team_requested)
	print("Player", plr, "requests to join team:", team_requested)
	if team_requested == "Noob" and #teams.Noob:GetPlayers() == 0 then
		print("They successfully joined noob team")
		plr.Team = teams.Noob
		sg.sys_team_ui.Enabled = false
	elseif team_requested == "Zombie" and #teams.Zombie:GetPlayers() == 0 then
		print("They successfully joined zombie team")
		plr.Team =teams. Zombie
		sg.sys_team_ui.Enabled = false
	elseif team_requested == "Spectators" then
		print("They successfully joined spectators")
		plr.Team = teams.Spectators
		sg.sys_team_ui.Enabled = false
	else
		print("Failed to join team; team is full! Join a different one.")
	end	
end)

You can only change the UI on a localscript belonging to the player themselves

lol i am new to this., would a remote function work for this?

yes; you can send a remote event to the player telling them to toggle the UI