local wanderTarget
local wanderAngle
local wanderConeSize = 6
local maxWanderAngle = 1
function getWanderTarget()
math.random(tick())
wanderAngle = (math.random() - 0.5) * maxWanderAngle
rotatedLookVector = CFrame.Angles(0, wanderAngle, 0) * script.Parent.Torso.CFrame.lookVector
return (script.Parent.Torso.Position + wanderConeSize * rotatedLookVector)
end
while true do
local ray = game.Workspace:FindPartOnRay(Ray.new(script.Parent.Torso.Position, script.Parent.Torso.CFrame.lookVector * 5.0), nil)
if ray and script.Parent.Humanoid then
script.Parent.Humanoid.Jump = true
end
wanderTarget = getWanderTarget()
script.Parent.Humanoid:MoveTo(wanderTarget, script.Parent.Torso)
wait(0.125)
end
This should work for you any issue reply to this and i can help you.
local wanderTarget
local wanderAngle
local wanderConeSize = 6
local maxWanderAngle = 1
math.randomseed(tick())
function getWanderTarget()
wanderAngle = (math.random() - 0.5) * maxWanderAngle
local rotatedLookVector = (CFrame.Angles(0, wanderAngle, 0) * script.Parent.Torso.CFrame.LookVector).Unit
return (script.Parent.Torso.Position + wanderConeSize * rotatedLookVector)
end
while true do
local ray = game.Workspace:FindPartOnRay(Ray.new(script.Parent.Torso.Position, script.Parent.Torso.CFrame.LookVector * 5.0), nil)
if ray and script.Parent.Humanoid then
script.Parent.Humanoid.Jump = true
end
wanderTarget = getWanderTarget()
script.Parent.Humanoid:MoveTo(wanderTarget, script.Parent.Torso)
wait(0.125)
end