How to create a NextBot

Hello everyone. In this topic, you should be able to create a NextBot like the ones in Garry’s Mod. Let’s begin.

The first thing you would want to do is create an R6 rig. This can be done by using the rig builder plugin that is pre-installed. Don’t rename the rig yet, keep set it to "Dummy"

Once you have your rig in place, you need to add 2 attachments within the torso of your rig.
SET YOUR SNAP-TO-GRID INCREMENT TO 0.5 and move one attachment to the bottom of the rig’s feet, and the other 7-10 studs in the air. Name the bottom attachment “Attachment1” and the other "Attachment0"

Congrats! You’ve finished the setup, now it’s time to make this a NextBot!
Paste this script into the command bar:

local dummy = game.workspace.Dummy
local attach1 = dummy.Torso.Attachment1
local attach0 = dummy.Torso.Attachment0

local beam = Instance.new("Beam")

beam.Attachment0 = attach0
beam.Attachment1 = attach1

beam.LightInfluence = 1
beam.TextureSpeed = 0
beam.Texture = "rbxassetid://10362146767"
beam.TextureMode = Enum.TextureMode.Stretch
beam.FaceCamera = true

beam.Width0 = 10
beam.Width1 = 10

beam.Parent = dummy 

If you’ve correctly set up the rig, you should see a semi-transparent NextBot in your workspace. Go into the rig and select the beam. Change the Transparency to 0. Also, select all the body parts in your rig, turn CanCollide off, and change Transparency to 0. Delete the face decal located in the head. What this script did was automatically add a beam to your rig, and connect it to the attachments you made earlier. I just saved you from going through the process of manually setting up the beam, you’re welcome. P.S. MAKE SURE THE "HumanoidRootPart IS UNANCHORED!!!

Now that is all left to do is make the NextBot chase you. There are many ways to do this, but this post isn’t about enemy ai. I’ll provide a basic enemy chase script here:

local npc = script.Parent
local hrpOfNPC = npc:WaitForChild("HumanoidRootPart")

local plrsHit = {}
local maxDistance = math.huge

npc.Humanoid.Touched:Connect(function(touch)
	if game.Players:GetPlayerFromCharacter(touch.Parent) and not plrsHit[game.Players:GetPlayerFromCharacter(touch.Parent)] then
		plrsHit[game.Players:GetPlayerFromCharacter(touch.Parent)] = true	
		touch.Parent.Humanoid:TakeDamage(100)		
		wait(1)

		plrsHit[game.Players:GetPlayerFromCharacter(touch.Parent)] = false	
	end
end)

while wait() do	
	local plrs = game.Players:GetPlayers()
	local closestHRP	
	for i, plr in pairs(plrs) do		
		if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") and plr.Character.Humanoid.Health > 0 then		
			local hrp = plr.Character.HumanoidRootPart			
			local distanceBetween = (hrpOfNPC.Position - hrp.Position).Magnitude						
			if not closestHRP then closestHRP = hrp end		
			if (hrpOfNPC.Position - closestHRP.Position).Magnitude > distanceBetween then				
				closestHRP = hrp				
			end
		end
	end
	
	if closestHRP and (hrpOfNPC.Position - closestHRP.Position).Magnitude <= maxDistance then npc.Humanoid:MoveTo(closestHRP.Position) end
end

By the way, this is a regular script inside the rig.
Boom! You have your very own NextBot. If you would like to change the NextBot texture, just select the beam and change the id of the beam’s texture. You can also change the speed of the NextBot by selecting “Humanoid” and changing WalkSpeed to your desired number.

If you’re having any trouble or there’s a part you don’t understand, just shoot me a question in the comments. Until next time!

44 Likes

Good tutorial, but it’s not completely necessary to import an r6 rig.
All you really need is a Humanoid, a hitbox, a decal OR the 2 attachments and a script.

7 Likes

Thanks now I can make survival the GM_Construct at 3 am. But seriously good tutorial.

2 Likes

Good tutorial, however nextbots arent just pngs they also need pathfinding.

5 Likes

there’s literally a script for pathfinding in the post

2 Likes

It’s not exactly a pathfinding script, it’s just a basic script that makes the NextBot follow/damage the player.

4 Likes

That is true, I just thought using a pre-made rig was easier.

1 Like

yeah good point my bad brother

2 Likes

Why is there no pathfinding?
image

@Beloathed It’s a simple chase script.

I really need to stop skimming these posts.

2 Likes

I appreciate the quick guide, however I noticed that once the nextbot kills me, it is no longer able to kill me again and just jumps up on top of me, is there any way to fix this?

I’m not sure, it could be the chase script isn’t very good. Is output saying anything?

I fixed it by removing the wait(1) in the attack function

1 Like

This is a nice tutorial, but I’m pretty sure a ton of developers are annoyed by the fact that others copy games that has get popular, such as Piggy, Nextbot, and that Donate Me game.

My point is these type of tutorials encourage people to make these “inspired” copies.
Good tutorial nonetheless.

Nextbots came from GMod, and theyre just pathfinding pngs. Not really encouraging copying. No where in here does he encourage it. If people use it to make copied games thats their choice not OPs. Thats like saying scripting tutorials encourage copying. Also what developers are mad? I dont see any.

3 Likes

I @AlbertsSoup say great job on the tutorial!

  1. You made a tutorial! (Verses others who don’t)
  2. I was sorta wondering how they / or this is done, just had not messed with it.
  3. It can be mod d , and use for other cool things.

enjoy the day!

1 Like

Hello @AlbertsSoup ! I really appreaciate the great and understandable Tutorial. Do you have any idea how to add a sound to it?

1 Like

You can insert a sound from the Roblox toolbox into the HumanoidRootPart. In properties, make sure isPlaying is enabled, as well as Looped if you want the sound to be repeated.

1 Like

Do you know how to do it? Please i can’t code