Pressing 'E' to open a door

So, basically what I am trying to do is chage the mechanics of a door script I made a few days ago from instead of clicking the door to open it, I want to be able to put my mouse over the door and when I press E on my keyboard it opens. Possibly add a GUI that displays text which says “Press ‘E’ To Open” as well

This is my current main door script that I am using which works perfectly fine but I wish to build on to it.

Keep in mind that I am very new to scripting and only have about 3 weeks of knowledge under my belt.

2 Likes

This script will be a lot more complicated, since it will require client-server communication. Unless this change is absolutely necessary, I wouldn’t suggest it.

However, here’s a quick rundown of what you need to do:
Client-side:
-Use :GetMouse() to have access to the mouse’s position
-Use .InputBegan to detect when something is pressed
-If the input’s KeyCode is equal to Enum.KeyCode.E, then
-Get whatever the mouse is on top of with Mouse.Target
-If it exists, use a RemoteEvent to send it to the server

Server-side:
-Detect when the RemoteEvent fires
-Use the mouse’s target to determine the door that is being hovered over (if any)
-CFrame the door like you did above

10 Likes

Seeing how I have no clue what half of what you just said does, I think I’ll just come back to this once I gain more scripting knowledge. Thanks!

7 Likes