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

How do I make a button that destroys the gui?

I made a script that deletes the GUI but when I reset, it's still there. Help.

script.Parent.MouseButton1Down:Connect(function()
	
	script.Parent.Parent.Parent:Destroy()
	
end)

3 answers

So, instead of using :Destroy(), you can use Enabled property of ScreenGui, if you are intending to destroy the ScreenGui.

script.Parent.MouseButton1Down:Connect(function()
	script.Parent.Parent.Parent.Enabled = false
end)

If it's other than ScreenGui, leave the comment and I'll help you with that. Lemme know if it helps!

2 comments

0

I tried it but when I reset, it get reenabled. How do I fix this?

0

Just set ResetOnSpawn to false using the code

This is very basic you use a local script and put it in the button and the script should be this:

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

That will remove it from the players GUI it you want it to still there do this:

Put a local script in the button and the script should be this:

script.Parent.ResetOnSpawn = false

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

if you put your GUI inside StarterGui, it will reset after you respawn, unless you toggle of ResetOnRespawn in the properties of the Screen Gui meaning it will not refresh after you reload your character.

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