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!