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
10 years ago

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

01local pg = game.Players.LocalPlayer.PlayerGui
02 
03if script.Parent.MouseButton1Click:connect(onSelect) then
04 
05    function onSelect()
06       pg.Gui:Remove()
07       wait()
08    end
09end
10 
11script.Parent.MouseButton1Click:connect(onSelect)
12 
13loop(math.huge)

2 answers

Log in to vote
0
Answered by 10 years ago

Hmm, try this;

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

Hope this helped!

0
Didn't work. It had a red line under your line 2 Danfly 5 — 10y
0
Strange, when I tested it in the Studio, it worked, I wonder why it has a red line under line 2? TheeDeathCaster 2368 — 10y
Ad
Log in to vote
0
Answered by 10 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