Anukun_Lucifer

MobScript(EP.10)

Feb 11th, 2024
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | Gaming | 0 0
  1. local physicsservice = game:GetService("PhysicsService")
  2. local serverstorage = game:GetService("ServerStorage")
  3. local serverstorage = game:GetService("ServerStorage")
  4.  
  5.  
  6.  
  7. local mob = {}
  8.  
  9. function mob.Move(mob, map)
  10.     local humanoid = mob:WaitForChild("Humanoid")
  11.     local waypoints = map.Waypoints
  12.  
  13.     for waypoint = 1, #waypoints:GetChildren() do
  14.         humanoid:MoveTo(waypoints[waypoint].Position)
  15.         humanoid.MoveToFinished:Wait()
  16.     end
  17.  
  18.     mob:Destroy()
  19.  
  20.     map.Base.Humanoid:TakeDamage(humanoid.Health)
  21.  
  22. end
  23.  
  24. function mob.Spawn(name, quantity, map)
  25.     local mobExists = serverstorage.Mobs:FindFirstChild(name)
  26.  
  27.     if mobExists then
  28.         for i=1, quantity do
  29.             task.wait(0.5)
  30.             local newMob = mobExists:Clone()
  31.             newMob.HumanoidRootPart.CFrame = map.Start.CFrame
  32.             newMob.Parent = map.Mob
  33.             newMob.HumanoidRootPart:SetNetworkOwner(nil)
  34.  
  35.             for i, object in ipairs(newMob:GetDescendants()) do
  36.                 if object:IsA("BasePart") then
  37.                     physicsservice:SetPartCollisionGroup(object, "Mob")
  38.                 end
  39.             end
  40.  
  41.             newMob.Humanoid.Died:Connect(function()
  42.                 task.wait(0.5)
  43.                 newMob:Destroy()
  44.             end)
  45.  
  46.             coroutine.wrap(mob.Move)(newMob, map)
  47.         end
  48.     else
  49.         warn("Requested mob dose not exist",name)
  50.     end
  51. end
  52.  
  53. return mob
Tags: Roblox
Add Comment
Please, Sign In to add comment