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

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

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

✓ Accepted answer

--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.

2 comments

0

@LeanXeno gaaaah thank youu! Sorry my brain had a bruh moment; I've been at this for hours.

0

Accept the question please. Another thing is that Remove is deprecated and you should use Destroy() or AddItem() ( using debris service )

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