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

Why doesn't think script close the GUI?

Asked by
Danfly 5
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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!

0
Didn't work. It had a red line under your line 2 Danfly 5 — 9y
0
Strange, when I tested it in the Studio, it worked, I wonder why it has a red line under line 2? TheeDeathCaster 2368 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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)

Answer this question