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

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

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?

1 comment

0

Are you not using ClickDetectors?

2 answers

✓ Accepted answer

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.

3 comments

0

mouseClick is deprecated u noob

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.

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.

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

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