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

GUI wont destroy its self when I click the exit button? [FE]

I've got a shop npc. When you click on their head, it clones a shop gui into the PlayerGui, but when I click exit shop it wont destroy its self.

When I use a LocalScript, it destroys it, but the game wont put the Gui back because the server still thinks that the gui is in the player's PlayerGui.

When I use a Server-Sided script, it just flat out wont work. I assume that's because the server cant access the PlayerGui?

Here is the script that controls the shop closing:


 function rek()
script.Parent.Parent.Parent:Destroy()
end

script.Parent.MouseButton1Click:Connect(rek)

2 comments

0

where is this script located?

0

It is located in the exit button

3 answers

✓ Accepted answer

Since it's filtering enabled, server scripts do not work in PlayerGUI. You must use a local script. I can't help with the fact it won't give a new GUI unless you share the script it clones from. Thanks.

function close()
Local Exit = game.StarterGui.ExitButtonName
if Exit.MouseButton1Click = true then
GuiName:Destroy()

PLEASE REPLY IF IT DOES NOT WORK AND I WILL GET BACK TO YOU Also put it in the Exit Button

Thanks for the help but I figured it out on my own.

s = script.Parent

s.ClickDetector.MouseClick:Connect(function(p)
local box = "KatanaShop"
local gui = p.PlayerGui:FindFirstChild(box)
game.ReplicatedStorage:FindFirstChild(box):Clone().Parent = p.PlayerGui
end)

That script clones the gui to the player's GUI.

It does not require the Gui to not be there.

For the server, the player will still have the gui, but the player cant see it so.

Not the most elegant solution, but it works

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