How would I Make a Npc wander to the Closet Player

So I making AI for a Horror game I made AI for the NPC to follow the closet Player, but if the player the AI just stands there, Not really realistic
image

You need to show us your code. We cant fix code if we have none to work with.

I dont have code i said i dont know how to do it LOL

you just need to do a loop with a for i v loop in it that will detect which player HumanoidrootPart magnitude is less if it is less then the ai can walk to the player you add it as if its less than 40 then the ai can walk to the player which if all the player isnt less than 40 then the ai stay in place

1 Like

Have a script loop through every player in the game, then get the closest HumanoidRootPart by using magnitude.

local distance = (NPC.PrimaryPart.Position - HumanoidRootPart.Position).magnitude

Then just get the lowest one and done, have it walk to that position.

O so I don’t need to use DistanceFromCharacter?

Could I use this

					print("Mr rake did not a Player")

then put that code

image

Well can I send the code for the AI to follow the closet player and can you teach me how to make the AI wander?

i dont have the time for scripts but here is some video: