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

Open a Gui once clicking a brick?

Hello,

So I have made a script were if you click a part it will pop a gui open for you! But when I close the gui it does not reopen!

GUI script - https://gyazo.com/d207cc15c144a6fe317fef5001405045 Close script for gui - https://gyazo.com/1c11cd1d56e638e6ae944b6aa0e2e0d5

Also the GUI script is a normal script and the close script is a local script!

2 comments

0

can't use findfirstchild("playergui") on serverscripts, you can only do thing.Parent = player.PlayerGui (yes it works I tested it)

0

o no!

1 answer

✓ Accepted answer

The link you sent is outdated so I made this from my own head:

Use a Local Script and insert it to StarterGui. Insert you ScreenGui to the Part's ClickDetector

local player = game.Players.LocalPlayer -- Define the local player
local playerGui = player:WaitForChild("PlayerGui") -- Define the player's player gui

local part = workspace:WaitForChild("Part") -- Change the 'part' to your part
local cd = part:FindFirstChild("ClickDetector") -- Define the click detector

local gui = cd:FindFirstChild("ScreenGui") -- Define your gui (insert it to part's click detector)

cd.MouseClick:Connect(function()
	if not playerGui:FindFirstChild(gui.Name) then
		gui:Clone().Parent = playerGui
	elseif playerGui:FindFirstChild(gui.Name) then
		playerGui:FindFirstChild(gui.Name):Destroy()
	end
end)

Now when you click the part, it opens the gui and when you click the part again it closes it.

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