How to make an object chase the player in Roblox Studio (: MoveTo)

In this post I will show you how to make a character chase the player across the map in Roblox Studio.

Game Link:

1 – Part ➔ Block: Creating a portal where enemies will be born
This portal was created using the Part ➔ Sphere tool. In the portal we insert ParticleEmitter and Transparency effect

2 – Part ➔ Sphere: Creating an enemy using the Sphere
The Enemy was created using the Part ➔ Sphere tool, a giant ball.
We set the color, change the “Material” to “Neon” which generates the glow effect.
For the chase script to work you need:
➔ Transform the Sphere into "Model" by grouping "CTRL + G"
➔ Insert the “Human” object
➔ Insert the "Surface" in the Object

3 – Chase Script: Script that makes the Enemy chase the Player

moving objects

local object = script.Parent while (true) do wait(0.1) object.Position = object.Position + (0,0.1) end

How to make an object chase the player

  • Block must have HumanoidRootPart
  • You have to turn it into Surface
local distancemax = 200 -- 20 meters for NPC to chase Follow local player distance min = 20 -- 5 minimum distance for bot to stop function player() repeat wait() until game.Players.NumPlayers >= 1 -- wait until the number of players is greater than 1 or equal local NPC = script.Parent local NPCHumanoidRoot = NPC.HumanoidRootPart local NPCHumanoid = NPC.Humanoid for i,v in pairs(game.Players:GetPlayers()) do -- Get the list of players repeat wait() until v.Character -- Wait for player character -- chase if (v.Character.HumanoidRootPart.Position - NPCHumanoidRoot.Position).Magnitude <= distancemax and (v.Character.HumanoidRootPart.Position - NPCHumanoidRoot. Position).Magnitude >=distancemin then NPCHumanoid:MoveTo(v.Character.HumanoidRootPart.Position -,distancemin,0)) if v.Character.Humanoid.Jump == true then -- if the player skips the npc will also skip NPCHumanoid.Jump = true end NPCHumanoidRoot.Touched:Connect(function(hit) -- damage player wait(1) if hit.Parent:FindFirstChild("Humanoid") then wait(1) hit.Parent:FindFirstChild("Humanoid"):TakeDamage(0.05) end end) end end while player wait() end

Other references
Video 1

Video 2

Video 3

Video 4

Video 5

Video 6

Fabio Bmed on Social Media

Fabio Bmed no Youtube

Fabio Bmed no TikTok

Fabio Bmed no Facebook

Fabio Bmed no Instagram

Fabio Bmed na Twitch

Fabio Bmed no Twitter

 509 Total Visualizações,  1 Visualizações Hoje

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.