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

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

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

local Part = script.Parent

Part.Touched:connect(function(HIT)
	local H = HIT.Parent:FindFirstChild("Humanoid")
	if H then
		local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
		Player.PlayerGui.NPC.ChatGuiOne.Frame.Visible = true
	end
end)

^ This isn't the problem, it works fine

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

StarterGui
	NPC --Folder
		ChatGuiOne --ScreenGui
			Frame
				CloseButton --TextButton
					LocalScript

This is what that LocalScript looks like:

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

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:

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

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

1 answer

✓ Accepted answer

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

local on = true

function off()
if on == true then
on = false
game.Players.LocalPlayer.PlayerGui.NPC.ChatGuiOne.Frame.Visibiel = false

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