Clicking on a Part while a Tool is equipped

I am trying to make doors that can be unlocked while the player is holding the corresponding key. The key that I am using is a Tool, so I cannot use a ClickDetector to detect when the player clicks the part.

I know that Mouse.Target could be used to detect the clicked part, but this is client-side. I need to have the door open on the server-side so that it will open for all players. Is there any way I could pass the specific “door” part from the client to the server and handle the door opening on the server?

I really am just looking for a way to detect on the server side when a player clicks a part, while the player is holding a tool.

1 Like

you can use remote events and

1 Like

If the original usage of Mouse.Target worked try using remote events to send information to the server about the door and open it from there.

1 Like

How do I tell the server which door was opened with the key? There is no way to pass the actual Instance to the server side


You can give each door a unique attribute called (for example) Id which would store a number type, then when the client sends a request to the server, it sends over the Id attribute of that door to the server, so the server now knows which one to open. If you do this make sure to use sanity checks so exploiters cannot open a door from 1,000 studs away.

I think I will go for this approach, it seems like there’s not a better way to find the clicked part on the Server side.