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 open GUI when i click a part?

The title explains it all, i want to enable a GUI when i click a part. any help is appreciated. Thank you!

1 answer

✓ Accepted answer

put a click detector inside the part and put this script (a local script) directly inside of your gui. you can figure out when a player clicks a part using a click detector

Localscript:

--Examples: part = workspace.ClickPart, part = workspace.Baseplate
local part = location of part in the workspace 

local gui = script.Parent 

part.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
	if playerWhoClicked == game.Players.LocalPlayer then
		gui.Enabled = true
	end
end)

You can also do this in a server script:

local part = location of part in the workspace --Example: part = workspace.ClickPart, part = workspace.Baseplate, part = script.Parent

part.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
	----if my gui was named partGui, then i'd say playerWhoClicked.PlayerGui.partGui.Enabled = true

	playerWhoClicked.PlayerGui.NAME OF GUI.Enabled = true
end)

1 comment

0

Thank you!

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