function Click(mouse) while wait() do game.Players.LocalPlayer.PlayerGui.CTGUI:Remove() end end script.Parent.MouseButton1Click:connect(Click)
This removes the GUI from the player GUI after he clicks a team but it only removes it the first time then he respawns and it is there again.
It seems you are a beginner, so let's do this slowly.
First thing (not necessarily part of the answer): the :Remove()
method is deprecated, use :Destroy()
instead.
Ok, now the answer.
Probably (since you didn't give details) that CTGUI
is inside StarterGui. The StarterGui is where everything in the screen will be loaded when the player respawns, so that CTGUI
can't be placed there, you need to place it directly to the PlayerGui.
Also, that while wait() do
makes absolutely no sense there. It is a infinite loop in the middle of a function that will be used only once, so you can discard it.