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

Why doesn't think script close the GUI?

This is a click button one. What is wrong with it it won't close the scripts!

local pg = game.Players.LocalPlayer.PlayerGui

if script.Parent.MouseButton1Click:connect(onSelect) then

    function onSelect()
       pg.Gui:Remove()
       wait()
    end
end

script.Parent.MouseButton1Click:connect(onSelect)

loop(math.huge)

2 answers

Hmm, try this;

wait(0) --Waits 0 seconds before loading script
script.Parent.MouseButton1Click:connect(function() --Player Clicked Gui (Has to be a TextButton)
--Rest of coding
end) --The end for the event/function

Hope this helped!

2 comments

0

Didn't work. It had a red line under your line 2

0

Strange, when I tested it in the Studio, it worked, I wonder why it has a red line under line 2?

I use this evevnt/function most of the times for TextButtons, and it works most of the times try using this: ;) I hope I helped

script.Parent.MouseButton1Down:connect(function() -- What your code here for the TextButton, put it in here end)

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