Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

does anyone know how to change this random walk script into a controlled walk?

Asked by
Xeilot -1
5 years ago
Edited 5 years ago

Anyone know how to turn a random walk into something like a patrol? like first the NPC moves forward, then turns right, then moves for 30, then turns left, and goes through like a building.

here is the script rn and i cant seem to get it to work, when i try to do a bigger number, it just doesn't move



local CurrentPart = nil local MaxInc = 99999 function onTouched(hit) if hit.Parent == nil then return end local humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid == nil then CurrentPart = hit end end function waitForChild(parent, childName) local child = parent:findFirstChild(childName) if child then return child end while true do print(childName) child = parent.ChildAdded:wait() if child.Name==childName then return child end end end local Figure = script.Parent local Humanoid = waitForChild(Figure, "Humanoid") local Torso = waitForChild(Figure, "HumanoidRootPart") local Left = waitForChild(Figure, "LeftFoot") local Right = waitForChild(Figure, "RightFoot") Humanoid.Jump = true Left.Touched:connect(onTouched) Right.Touched:connect(onTouched) while true do wait(math.random(87, 87.00001)) if CurrentPart ~= nil then if math.random(87, 87.00001) == 1 then Humanoid.Jump = false end Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-MaxInc, MaxInc), 0, math.random(-MaxInc, MaxInc)), CurrentPart) end end
0
it'd be easier to recode it NukemDukeForNever 0 — 5y
0
findFirstChild is deprecated use FindFirstChild, and == nil is irrelevant User#19524 175 — 5y
0
how does that help? he is still stuck still Xeilot -1 — 5y

Answer this question