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

How to make a part that when you click on it it opens a GUI?

Asked by 4 years ago

Ive tried this script but it doesn't seem to work:

script.Parent.MouseButton1Down:Connect(function()
   game.StarterGui.PurchaseGUI.Frame=true
end

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Make sure this is in a local script in StarterGui, and that you replace the variable.

local part = game.Workspace.Part -- Your part here
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")

part.ClickDetector.MouseClick:Connect(function()
    playerGui.PurchaseGUI.Enabled = true
end)

The PlayerGui is what the players see, so you need to put that there to enable it for a certain player.

0
You also need to make sure that the part you want to click to open it has a ClickDetector. ParticularlyPenguin 71 — 4y
0
When I press the button the GUI Doesn't pop up and i get this response: PurcahseGUI is not a valid member of PlayerGui Snaprocitz5 8 — 4y
0
What's the ScreenGui's name? ParticularlyPenguin 71 — 4y
0
PurchaseGUI Snaprocitz5 8 — 4y
View all comments (5 more)
0
Edited. Should work now. ParticularlyPenguin 71 — 4y
0
Just tested it and it works now! Thanks! Snaprocitz5 8 — 4y
0
No problem! Please accept my answer. ParticularlyPenguin 71 — 4y
0
sorry, im new to this, how do i do that? Snaprocitz5 8 — 4y
0
Hover over my answer and there should be a thing that says 'accept answer'. Sorry for late reply, my wifi went down for like 2 minutes. ParticularlyPenguin 71 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

ClickDetector use MouseClick Event, and you could use the parameter:

script.Parent.ClickDetector.MouseClick:Connect(function(PlayerWhoClickedNotCharacter)
    PlayerWhoClickedNotCharacter.PlayerGui.PurchaseGUI.Enabled = true
end)

Also i don't understand what u mean by .PurchaseGUI.Frame, so i changed it to .PurchaseGUI.Enabled

0
I don't believe ClickDetectors use any parameters, but okay. ParticularlyPenguin 71 — 4y
0
Yes it does Nguyenlegiahung 1091 — 4y
0
Apologies, I was told otherwise by someone else. ParticularlyPenguin 71 — 4y
0
It's ok, you learn something new everyday Nguyenlegiahung 1091 — 4y

Answer this question