Hi I have some deers spread all around the valley, that are using pathifing service to move around. Here is a cut of my script that is responsible for its moving:
way = torso.Position
local path = service:CreatePath()
local vX = math.random(torso.CFrame.X - 400, torso.CFrame.X + 400)
local vZ = math.random(torso.CFrame.Z - 400, torso.CFrame.Z + 400)
local part = Instance.new("Part", game.Workspace)
part.Transparency = 1
part.Position = Vector3.new(vX, 0, vZ)
wait(2)
path:ComputeAsync(torso.Position, part.Position)
local waypoints = path:GetWaypoints()
part:Destroy()
return waypoints
But they all end up on the same area, like shown in this video:
robloxapp-20200929-2100245.wmv (3.2 MB)
I already heard before that math.random() is not the best at generating random numbers, but is this the problem here or anything else?
I also know u would be interested into variables, so here they are:
local service = game:GetService("PathfindingService")
local hum = script.Parent.Humanoid
local torso = script.Parent.Torso
local way = torso.Position -- way doesn't play a role in this part of script
Thanks for your help!