So I've taken up learning the ContextActionService. The best place to start seemed to be a door. While the script I have works fine, it feels inefficient. The idea of having to keep hundreds of doors stored in a folder and checking each individual one in a for loop seems like a bad solution to make this work. I was thinking of having the action be bound an unbound to open one specific door if the player came within a radius of it but I'm not entirely sure how to accomplish this.
Two methods I know would work are:
An invisible part with a Touched event
A while loop checking if the player is within a certain radius
Both options though seem very unappealing. Touched is a mess a lot of the time and I really don't like the idea of having a constant loop going that's constantly running checks given how common things like doors can be in maps. I've heard of using a Changed event but from what I've tested, Changed will not fire for player movement and neither will GetPropertyChangedSignal.
So what IS the best possible means of accomplishing something like this?
This is just a random idea but maybe it will work
You could have the client check if it's near any doors, and if it is, it sends a RemoteEvent to the server with the door it's near. The server then checks if the player really is near the door, and if it is, it opens it.
While there might be a delay between the player walking to the door and the door opening, in terms of computational power it's pretty efficient - loops are only run for one player on each client (no server strain unless a client spams the event, for which you can add a debounce or something). It shouldn't impact the client much, especially if you make it check for doors only once a while, something like once a second or so
Hope this helped :D