Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why will my gui not go invisible when you click the text button?

clickedbutton = game.StarterGui.Startgui.Frame.TextButton
	clickedbutton.MouseButton1Click:connect(function(guiplayer)
		guiplayers  = game.Players:GetPlayerFromCharacter(guiplayer.Character)
	gui = guiplayers.PlayerGui:FindFirstChild("Startgui")
		
		if gui then
			

			gui.Frame.Visible = false
		
		end
		end)

2 answers

✓ Accepted answer

The GUI object in StarterGui is separate from the GUI objects in a player's PlayerGui. Therefore, setting a variable to the GUI in StarterGui will not allow your players to click the button.

Put this in a LocalScript inside your TextButton:

local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
    if player.PlayerGui:FindFirstChild("Startgui") then
        player.PlayerGui.Startgui.Visible = false
    end
end)
button = script.Parent
function onClicked()
	button.Visible = false
end
button.MouseButton1Down:connect(onClicked)

i dont know any of that nonsense up there but to make a gui go invisible this is how i would do it

button = script.Parent
function onClicked()
	if button.Visible == true then
		button.Visible = false
		else button.Visible =true
	end
end
button.MouseButton1Down:connect(onClicked)

this is if you want to toggle between on and off

This discussion is preserved as it was. New answers, comments, and votes are closed.