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

How do I make a succesful close button for my Pop-up Gui?

Asked by 7 years ago

So I made a script where when a brick is touched a Gui opens:

1local Part = script.Parent
2 
3Part.Touched:connect(function(HIT)
4    local H = HIT.Parent:FindFirstChild("Humanoid")
5    if H then
6        local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
7        Player.PlayerGui.NPC.ChatGuiOne.Frame.Visible = true
8    end
9end)

^ This isn't the problem, it works fine

This is kinda what my StarterGui looks like in the Explorer:

1StarterGui
2    NPC --Folder
3        ChatGuiOne --ScreenGui
4            Frame
5                CloseButton --TextButton
6                    LocalScript

This is what that LocalScript looks like:

1script.Parent.MouseButton1Click:connect(function()
2    script.Parent.Parent.Visible = false
3end)

This didn't work so I thought maybe the problem was something to do with everything in StarterGui being cloned into PlayerGui, so I tried this:

1script.Parent.MouseButton1Click:connect(function()
2    game.Players.LocalPlayer.PlayerGui.NPC.ChatGuiOne.Frame.Visible = false
3end)

Neither of them work. I hope I gave enough detail for someone to help me out. :-)

1 answer

Log in to vote
0
Answered by 7 years ago

If you already made the open button, and it's scripted that means the frame should now be visible, so with the close button ...

1local on = true
2 
3function off()
4if on == true then
5on = false
6game.Players.LocalPlayer.PlayerGui.NPC.ChatGuiOne.Frame.Visibiel = false
Ad

Answer this question