Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Erik's Wanders v1.0.0 --
- local canWander = true -- Randomly walk around while idle
- local WanderX, WanderZ = math.random(5, 15), math.random(5, 15) -- Wander distance
- local NPC = script.Parent
- local human = NPC:WaitForChild("Humanoid")
- local hroot = NPC:WaitForChild("HumanoidRootPart")
- local isWandering = 0
- if canWander then
- spawn(function()
- while true do
- if isWandering == 0 then
- isWandering = 1
- 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)
- human:MoveTo(Vector3.new(desgx, desgy, desgz))
- wait(math.random(4, 6))
- isWandering = 0
- end
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement