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

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

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

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

2 answers

✓ Accepted answer

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.

9 comments

0

You also need to make sure that the part you want to click to open it has a ClickDetector.

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

0

What's the ScreenGui's name?

0

PurchaseGUI

0

Edited. Should work now.

0

Just tested it and it works now! Thanks!

0

No problem! Please accept my answer.

0

sorry, im new to this, how do i do that?

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.

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

5 comments

0

I don't believe ClickDetectors use any parameters, but okay.

0

Yes it does

0

Apologies, I was told otherwise by someone else.

0

It's ok, you learn something new everyday

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