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

Open a Gui once clicking a brick?

Asked by 5 years ago

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!

0
can't use findfirstchild("playergui") on serverscripts, you can only do thing.Parent = player.PlayerGui (yes it works I tested it) Imperialy 149 — 5y
0
o no! TheluaBanana 946 — 5y

1 answer

Log in to vote
0
Answered by
MiguRB 60
5 years ago
Edited 5 years ago

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.

Ad

Answer this question