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

How do I program an on-click function?

Asked by 10 years ago

I have an exclamation mark that I use as a quest giver but I haven't programmed in a long time so I forgot almost everything. I want the player to be able to click on the exclamation mark, and then have a gui pop up describing the quest, or just any info. Can anyone give the me on click function? If it has to create a gui with Instance.new then so be it.

1 answer

Log in to vote
1
Answered by 10 years ago

First, add a click detector to the exclamation mark and modify it to whatever you want. Next get the click detector's path (EX. game.Workspace.Model.ClickDetector) and then add the MouseClick event to it like so:

game.Workspace.Model.ClickDetector.MouseClick:connect(function()
    --code goes here
end

After that you will need to open the gui, so you will need the gui's path. Then you will need to make the .Visible property to true so it will appear on their screen.

game.Workspace.Model.ClickDetector.MouseClick:connect(function()
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Gui.Visible = true;
end
Ad

Answer this question