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

Click detector to open a gui. help?

i need help With this to work. i will not show up the gui when i click the part

function onClicked()
	game.StarterGui.ScreenGui.ImageLabel.Visible = true
	wait()
end

script.Parent.Clicked:connect(onClicked)

3 comments

0

You can't use Click detctors in Gui's. Use a Text button gui and put that code in a Local script inside the Text button.

0

KenzaXI, you CAN use a Part with a ClickDetector to give a player the GUI. Afterall, MouseClick does return the player who clicked.

0

a GUI in startergui is cloned to PlayerGui inside each player when they enter/die

1 answer

it appears you want to use a Part with a ClickDetector. So I will help because what you're doing would not function properly!

Lets go over some basics, you cannot edit a GUI StarterGui and expect the player to see the new edits. You must edit the GUI inside of the PlayerGui, found as a Child of Player. Now, you want to use the correct event and I assume the script is a Script inside of the Part and the Part has a ClickDetector inside!

ClickDetector uses MouseClick to fire when a player clicks on a part. Now with this knowledge, we will make the script correctly!

function onClicked(PlayerWhoClicked) 
	PlayerWhoClicked.PlayerGui.ScreenGui.TextLabel.Visible = true
	wait() -- You do not need this here.
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

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