How to call a function when a click detector detects a click?

Hello, I’m scripting a nuclear control room and am fairly new to scripting. I’m trying to animate control rods inserting on a monitor when the control rod throttle is in a certain position. However, I’m unsure of how to call the function which makes the next level of inserted control rods (on the monitor) appear when the click detector for the control rod throttle is clicked. Essentially, I’m not sure how to call a separate function when a separate click detector is activated. I know this seems vague, but could I get a bit of guidance?

Much appreciated,
Ridgeon

1 Like

Pls search on the internet:
https://developer.roblox.com/en-us/api-reference/event/ClickDetector/MouseClick

Its a event, you can search how to handle events.

You really have tons of videos that can help you, so first search

So now for this:

I would use RemoteEvents to make that the animation is visible to the others

3 Likes

There’s a MouseClick event for a click detector that fires whenever the click detector is clicked. You can use Connect to connect the function to that event and make it run whenever that event fires.
Example:

function onclick()
    print( "The click detector was clicked!" )
end

Yourclickdetector.MouseClick:Connect(onclick())
1 Like