Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't the ScreenGui be destroyed?

Asked by
ExcelUp 24
6 years ago
Edited 6 years ago

I have a button in my ScreenGui that when pressed is supposed to destroy the ScreenGui it is apart of. When I test this in a local server on Studio, when the button is pressed, the ScreenGui itself disappears, but the actual item in the PlayerGui is still there.

Why won't the ScreenGui be destroyed?

Here's the code:

script.Parent.MouseButton1Click:Connect(function() --script.Parent is the TextButton
    script.Parent.Parent:Destroy() --script.Parent.Parent is the Gui
end)
0
try making the gui a variable, so local gui = script.Parent.Parent (make sure you check your output) then do gui:Destroy() LukeGabrieI 73 — 6y
0
Already tried that. ExcelUp 24 — 6y
1
is your script a local script? If not convert it hellmatic 1523 — 6y
0
Server scripts can't make changes to the clients gui, only local scripts can hellmatic 1523 — 6y
View all comments (2 more)
0
Yeah I'm sure its not a local script or else this should work. ^^ TiredMelon 405 — 6y
0
It's a local script. ExcelUp 24 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

This is due to the ResetOnSpawn property of the ScreenGui. Set it to false and it should destroy when you ask it to.

Ad
Log in to vote
0
Answered by 6 years ago

Try this, this just gets it out of the localplayers GUI.

script.Parent.MouseButton1Click:Connect(function() --script.Parent is the TextButton
   local gui = game.Players.LocalPlayer.PlayerGui.GUINAME -- Change the name to your GUI's Name
local dgui = gui:Destroy()

end)
0
Completely unnecessary code. local dgui wouldnt work since the gui is destroyed it should be game.Players.LocalPlayer.PlayerGui.GUINAME:Destroy() Sergiomontani10 236 — 6y

Answer this question