Advertisement
Anukun_Lucifer

MobScript

Oct 19th, 2023
4,992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | Gaming | 0 0
  1. local serverstorage = game.ServerStorage
  2. local mob = {}
  3.  
  4. function mob.Move(mob, map)
  5.     local humanoid = mob:WaitForChild("Humanoid")
  6.     local waypoints = map.Waypoints
  7.  
  8.     for waypoint = 1, #waypoints:GetChildren() do
  9.         humanoid:MoveTo(waypoints[waypoint].Position)
  10.         humanoid.MoveToFinished:Wait()
  11.     end
  12.    
  13.     mob:Destroy()
  14.    
  15. end
  16.  
  17. function mob.Spawn(name, quantity, map)
  18.     local mobExists = serverstorage.Mobs:FindFirstChild(name)
  19.    
  20.     if mobExists then
  21.         for i=1, quantity do
  22.             task.wait(0.5)
  23.             local newMob = mobExists:Clone()
  24.             newMob.HumanoidRootPart.CFrame = map.Start.CFrame
  25.             newMob.Parent = map.Mob
  26.            
  27.             coroutine.wrap(mob.Move)(newMob, map)
  28.         end
  29.     else
  30.         warn("Requested mob dose not exist",name)
  31.     end
  32. end
  33.  
  34. return mob
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement