I have lot of doors and I am scanning for player character parts.
Something that you can use is:
script.Parent.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if not player then return false end
– YOUR CODE HERE
end)
The touched event is pretty easy to use. What this does it that It checks if its a player, if not it won’t do anything. The hit = the thing that is touching, so the hit.Parent will be the player.
Yes this is for opening the door that is simple. I don’t want the door closing on them so, it waits every second until the area is empty and closes. This is what I am using GTP for and am reconsidering because it does not have an ignore list.
Spooks has created a video showing you how to create automatic doors. He used magnitude in this video to determine whether the player is in range or not.
It depends on how many doors there will be, how you code it, etc.
Region3s, from what I believe, can be a little expensive but I don’t believe they’re horribly expensive. As long as you don’t have hundreds - thousands of doors, you could possibly make them with such.
Touched is a bit less reactive and could mean that sometimes it doesn’t fire, however that’s often not the case.
I personally wouldn’t recommend using magnitude, as that’d require you to constantly check the players position and then get the magnitude, however if Spooks has an efficient way to do it then by all means, use it. Also, magnitude has a circle radius I believe as magnitude is the fastest route from point A to B, meaning it’d be a bit odd in some places.
I’d recommend though to use the region3 for this situation as it provides more freedom and allows you to know exactly when someone leaves/ enters the area, allowing for a nice door.