Advertisement
1m1m0

Erik.ai Wander/Idle

Jan 1st, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | Source Code | 0 0
  1. -- Erik's Wanders v1.0.0 --
  2.  
  3. local canWander = true -- Randomly walk around while idle
  4. local WanderX, WanderZ = math.random(5, 15), math.random(5, 15) -- Wander distance
  5.  
  6. local NPC = script.Parent
  7. local human = NPC:WaitForChild("Humanoid")
  8. local hroot = NPC:WaitForChild("HumanoidRootPart")
  9.  
  10. local isWandering = 0
  11.  
  12. if canWander then
  13.     spawn(function()
  14.         while true do
  15.             if isWandering == 0 then
  16.                 isWandering = 1
  17.                 local desgx, desgy, desgz = hroot.Position.x + math.random(-WanderX, WanderX), hroot.Position.y + math.random(5, 10), hroot.Position.z + math.random(-WanderZ, WanderZ)
  18.                 human:MoveTo(Vector3.new(desgx, desgy, desgz))
  19.                 wait(math.random(4, 6))
  20.                 isWandering = 0
  21.             end
  22.         end
  23.     end)
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement