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

How to always be able to open a screengui after clicking a part?

Asked by 4 years ago
Edited 4 years ago

So, I've been trying to make a computer model in my game that opens up a gui when you click the screen. It's semi-working; I can open it but when I close it and try to open it up again, nothing happens. I'm new to scripting, so it's probably something small I'm missing, but I'm not completely sure what to add to make it continuous? ;3;

Opening screengui code:

function Clicked(Plr)
   Plr.PlayerGui.GamePasses.Frame.Visible = true
end

script.Parent.MouseClick:connect(Clicked)

Close button code (in case this is the problem?)

button = script.Parent
window = script.Parent.Parent.Parent

function onClicked(GUI)
   window:remove()
end

script.Parent.MouseButton1Click:connect(onClicked)

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

--5 window:remove()

The :Remove() function does as it says, removes. You can't set the visibility of something that doesn't exist.

Better to toggle the visibility, as you did with the opening function of the script.

0
@LeanXeno gaaaah thank youu! Sorry my brain had a bruh moment; I've been at this for hours. Puppylovebug03 2 — 4y
0
Accept the question please. Another thing is that Remove is deprecated and you should use Destroy() or AddItem() ( using debris service ) Mr_Unlucky 1085 — 4y
Ad

Answer this question