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

My GUI wont go away when I click the X button?

So I made an Intro gui thats just a ImageLabel with a X button I made with the TextButton. I looked up a tutorial but the script didnt work for me when I tried to click the X.

script.Parent.MouseButtonClick:connect(function()script.Parent.Parent.Visible=false

end)

2 comments

0

After they click the button, will the gui show ever again?

0

No the GUI doesnt even go away

4 answers

✓ Accepted answer

its .MouseButton1Click your organization is also messed up

script.Parent.MouseButton1Click:Connect(function(lol)
	script.Parent.Parent.Visible = false
end)

4 comments

0

Perfect it works! But is there a way to make the GUI not pop up again?

0

:Destroy()

1

To answer your question, Shaletsgo, in the ScreenGui properties, there's a property called "ResetOnSpawn." Make sure that isn't checked.

0

tysm :D

Referencing GingeyLol, this is another way to do it using input:

UIS = game:GetService("UserInputService")
while true do
	wait()
	if UIS:IsKeyDown(Enum.KeyCode.O) then -- Open GUI
		for _,p in pairs(game.Players:GetPlayers()) do
			p.PlayerGui.ScreenGui.Enabled = true
		end
	end
	if UIS:ISKeyDown(Enum.KeyCode.X) then -- Close GUI
		if game.StarterGui.ScreenGui.Enabled ~= false then
			for _,p in pairs(game.Players:GetPlayers()) do
				p.PlayerGui.ScreenGui.Enabled = false
			end
		end
	end
end

Ok, so I think I understand what you need.

First off, you need to put it in a local script. (Always a local script if it's in the StarterGui)

After that, you may want to destroy the gui completely. Using a simple method, you can do this efficiently.

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent:Destroy()

Hope this helped.

Sincerely, 222ono222

3 comments

0

So I put that into a local script in the textbutton but It still didnt work

0

Nevermind I added a End on the 3rd line and it went away but is there a way to make it not pop up after a player resets

0

Yeah, just go into the screengui and turn off 'ResetOnSpawn'

myScreenGui = script.Parent -- you're path

game.Players.PlayerAdded:Connect(function(player)

if not player then repeat wait() until game.Players.LocalPlayer end

player.CharacterAdded:Connect(function(character)

if not character then repeat wait() until player.Character end

if not player:FindFirstChild("PlayerGui") then repeat wait until player.PlayerGui end

for i,v in pairs(player.PlayerGui:GetChildren()) do

if v.Name == myScreenGui.Name then

ScreenGui = v

else

return

end

end

if character.Humanoid.Died:Wait() then

character.Humanoid.Died:Connect(function()

if ScreenGui.ResetOnSpawn == false then ScreenGui.ResetOnSpawn == true

end

if ScreenGui.ResetOnSpawn == true then

2 comments

0

It didnt work

0

still doesnt work

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