Does anyone know how to make an npc block you from entering a door

Hi, so I am trying to make an NPC block a door like in this video ^ but I don’t know if its possible in roblox or where to start. I am not asking for like code Im just wondering if you know any documentation that would help. Thanks for stopping by.

6 Likes

you can probably use raycasting to check if the npc is there and if true then disable the door

4 Likes

No I want like the npc to block like go infront of the player not allowing them to move

1 Like

I’m not the best at scripting, but you could use Raycasting to detect the player, and make the NPC face them, moving in their way, and you could probably also weld an invisible wall to them.

Then again, I’m not sure if this is the most efficient way.

2 Likes

make a big invis wall with cancollide true so that the player cannot pass?

2 Likes

Ya lol I will be doing that but its this I want like the npc to face the player and block them

1 Like

Alright thanks I will try that

1 Like

use CFrame.lookAt() and turn to the nearest player

2 Likes

You can do like what this guy do but another way is doing CFrame.lookat() to all players in a certain range

1 Like

You could

  1. use a loop and some math to set the cframe of the npc according to the players position
  2. (this would only work for a straight line) set the position of the npc to the players position excluding one axis from the position
  3. set points near the blocked door that when near the npc moves there
2 Likes