How do I make a Smart AI?

Hello, I have been wondering how to make an AI for my Survival game. I’ve checked YouTube but what I can find is no video related to what I’m looking for. I have no idea how to make it.

I’ve already checked the link below but it strangely doesn’t work because of the word in the Lua Code “pathParams”.

image

5 Likes

Immediately below, it describes the parameters needed for the method.

3 Likes

Hello,

To answer your question, do not just put in “pathParams” just leave it blank.

In order to use the path that you just defined in a variable you need to tell the game where this NPC has to go by using :ComputeAsync() example: path:ComputeAsync(NPC_HumanoidRootPart.Position, Destination.Position/PrimaryPart) so basically you need to compute it in order to make it work.

Models use PrimaryPart instead of Position so do not forget to set the PrimaryPart before doing that.

Then once you have done that you can simply just say:

NPC_Humanoid:MoveTo(Destination.Position/PrimaryPart) and it will work, but this is just basic stuff, if you want to make your NPC smarter you will need to use the path waypoints and make a for loop to make the NPC move to them which can be found on the Pathfinding article here: Character Pathfinding | Documentation - Roblox Creator Hub

2 Likes

Okay, Ill do that and see what happens from there.

I tried the script and It didn’t work i’m really confused. I’ll try to find detailed YouTube videos about it.

1 Like

Yes. I’ve replaced the variable and still no luck.

1 Like

Pathfinding is somewhat complex, if you’re new to lua I’d reccomend starting off easy and moving off to pathfinding when you learn things like raycasting, and magnitude.

2 Likes

Oh, Thank you for explaining that to me I will look at easier stuff and learn raycasting and magnitude.

3 Likes