Creating an NPC that moves when not being looked at

I really wanna make an npc or block move when the user isin’t looking but when the user is looking at it i want it to not move at all, to be honest i just really need the method and that’s all, i don’t even know where to uh start, tried a lot of stuff and got a lot of help that didn’t work, so if anyone please?

i’m talking about like in the horror games where you look at the ghost it doesn’t move but then it does when you don’t look at it.

3 Likes

There is a method to do this, called :WorldToScreenPoint()

Here is an example of usage of this function of the Camera:

game:GetService('RunService').Stepped:Connect(function()
local Position, PlayerCanSee = Camera:WorldToScreenPoint(part.Position)
if PlayerCanSee then
-- Do something with our model.
end
end)
4 Likes

You could use a mix of WorldToViewportPoint and raycasting to make sure there is a ghost in front of you that you see and is in your viewport point.

1 Like