How to create an Animated, Intelligent, and Chasing Monster in Roblox?

Hello Roblox Developpers,

I’m trying to create a smart NextBot AI (like “Evade” or “Nico’s Next Bots”) in Roblox. I want it to be more advanced than the typical chase-and-attack behavior. Does anyone have tips or resources on how to make a more intelligent NextBot? I’d appreciate any advice or examples you can share. I have no clue on how to make one and i’ve tried to look it up but nothing was useful.

1 Like

Try pathfinding and raycasting to detect and chase players.

1 Like

As I said… I have no clue on how to make one. I don’t know how to use pathfinding and raycasting to detect players.

It’s like you just told me “Make one.”.

2 Likes

documentation on pathfinding
documentation on raycasting

2 Likes

i tried that… I didn’t really understand what to do.

1 Like

Someone released a Tutorial the other day:

1 Like

Hey, i just wanted to inform you that It’s not working for me. Did it work for you? if so, could u pls provide me a file?

I didn’t try what they said. I had read the article prior to seeing the question. Did you try the Toolbox link to grab the model?

yes.
(ignore : it says that i need to type more characters)

Your question is super vague, and depends a lot on what you already know. When you say you want to “make it more advanced than typical chase and attack”, are you saying that you’ve mastered this level of NPC AI and are looking to level up, or are you saying you know nothing about writing AI and expect to write state-of-the-art intelligent bots on your first attempt? Do you know the basics of coding finite state machines, behavior trees, GOAP, etc.?

Also, with regards to “smart” NPCs, there are different levels of smart. At one end of the spectrum you have basic, stupid NPCs that just chase and employ no tactics. A level up from that, you typically have NPCs that use pre-programmed, runtime heuristics and probability-based tactics to appear smarter. Heuristics typically include context information about the game (e.g. a buff just spawned at location X, players are probably heading there), and sometimes things like common player patterns developers learned from observation of real players, but they are sort of boiled-down “rules of thumb” for the NPC that are baked into their programming at authoring time. At the top-tier are true learning NPCs, these are genuine AI that can learn from player behavior patterns at runtime and adapt their strategies accordingly. You’re not going to write something in this last class on your first go, or second, etc.

Also worth mentioning is the fact that a lot of games don’t use real intelligence to make NPCs seem smarter and harder, they just let the NPCs cheat. For example: it’s easier to program an NPC to just have knowledge of where players are hiding than it is to program them to adaptively learn where players like to hide. It’s impossible to juke an NPC that can see though walls! The danger here is that it’s very easy to make the NPCs too good if you let them cheat. Like imagine if you were making a card game playing bot, and you let it know what cards were in all the other players’ hands…

1 Like

1-

wth is that?

2-

WHICH LEVEL DO YOU THINK I WANT? (the one that is smart enough to avoid obstacles… and jump)

3-

DO YOU EVEN KNOW WHAT A NEXTBOT IS? (it knows player’s location)

4-

Have you ever heard of something called “runnning” :running_man:

5-

:sob: … PLS PLAY “NICO’S NEXTBOT” OR “EVADE” (on roblox) (Just mentioning that it’s on roblox cuz you probably don’t know what these games are…)

6-

YEP! YOU DEFINITELY DON’T KNOW WHAT A NEXTBOT IS

7-
Am i speaking to an ai text writing user? like…

WHAT THE HELL DOES THAT EVEN MEAN!!?!?!?

I’m pretty sure what she meant to say was, based on your post, you wanted to make a “Smart Nextbot AI,” and you want it to be more complex than the usual Nextbots you might’ve seen before or even used before. But on the other hand, she’s not sure what’s the “Smart” level is for you. It may also seems like you don’t even know the basics on scripting, as you don’t even know how to use pathfinding and raycasting to detect players, yet you are looking to create “Smart AI.”

But worry not, I’ll try to help you as best as possible.

So first off, I’ll start with what’s a raycast.

Basicaly, raycast is just like shooting lasers in front of you until it hits something. In this case, we want it to detect players.

local NextBot = script.Parent
local RaycastParams = RaycastParams.new()

Now, we don’t want the laser to just detect nextbots as well right? Let’s say all the nextbots you made are placed in one folder in a workspace. So we just do,

RaycastParams.FilterDescendantsInstances = {workspace.Nextbots} -- Assuming this is where your nextbots are stored, you can also add other stuff in here
RaycastParams.FilterType = Enum.RaycastFilterType.Exclude

Alright, now to actually start with the raycast, we will use, for example, the nextbot’s torso (or the part that you put the decal in) and shoot the laser from there.

local Torso = NextBot.Torso -- Assuming your nextbot has a torso or a part that contains the decal
local direction = head.CFrame.LookVector * 20 -- How long the laser shoots based off where he is facing (20 studs)
local origin = Torso.Position -- Getting the origin position of the nextbot

local result = workspace:Raycast(origin, direction, RaycastParams) -- Using the origin of the laser, direction of where it goes, and the target, which excludes workspace.Nextbots as mentioned previously

if result then -- If it hits
        local hitPart = result.Instance
        local character = hitPart and hitPart.Parent -- Assuming we just hit a player
        local humanoid = character and character:FindFirstChild("Humanoid")

        if humanoid then -- Check if the result of the raycast has a Humanoid
            print("Player detected:", character.Name) -- Print for debugging
            -- You can trigger chase, attack, or alert behavior here
        end
    end

For starters, I recommend using Humanoid:MoveTo to make the nextbots chase the player, until you managed to get it to work. Once you are able to make a fully functional nextbot system, then you can proceed to learn on the usage of PathfindingService.