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

what event would i use if i wanted a function to fire when a part is clicked?

Asked by 6 years ago

Well im trying to make a makeshift select system but I cant make it work because i dont know what event i would use to detect when a part is being clicked?

0
Are you not using ClickDetectors? LastApollo 76 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Hello,

There is a method of running a function when a part is 'Clicked'.

ClickDetector

You can insert a ClickDetector into a part, where the script is located. This will make the part clickable, and will detect when a player has clicked a button.

If you run the code:

script.Parent.ClickDetector.mouseClick:connect(function()
    -- (Your Script Block)
end

Basically, the script will look at ClickDetector's hidden property called "mouseClick" which will detect if it was clicked by a mouse, then it connects itself to run a function.

If there are any problems that occured, please do respond in the comments.

Sincerley,

Arti_BLOX.

0
`mouseClick` is deprecated u noob creeperhunter76 554 — 6y
0
It is like saying ":Preload" is deprecated u noob. It can still be used, but :PreloadAsync would be a better way to do things. hiimgoodpack 2009 — 6y
0
Hello, It is deprecated, but it still works. This is a simple way to start learning it, and then go to a different route, in any cases, this method is simple and good for beginners for starting off with this kind of scripting. Arti_BLOX 58 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

insert a ClickDetector and type in a script in the part or somwhere else

script.Parent.ClickDetector.mouseClick:connect(function() 

end)

This the script if you put it in the part the script.Parent.ClickDetector selects the clickdetector and the mouseClick will activate the function if you click on the part

Answer this question