Issue with interaction with many objects

I have an interaction system, and i have multiple objects the player can interact to, there is a black ball, printing “Hello” when interacting, and a door opening when interacting, but when i try to open the door, it make the ball action, printing “Hello”, how can i fix this ?

Also, the Red function turn the crosshair/cursor red, and the White function turn it white.

Thank you in advance and sorry for my bad english, i’m french

Assuming you have a different class for the ball and door, if you implement an interaction interface, you can call the necessary events unique to each class on interact event.