In this post I will show you how to make a character chase the player across the map in Roblox Studio.
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
local object = script.Parent while (true) do wait(0.1) object.Position = object.Position + Vector3.new (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 - Vector3.new(0,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
Video 1 https://www.youtube.com/watch?v=M_JCH4ibqMo
Fabio Bmed on Social Media
509 Total Visualizações, 1 Visualizações Hoje