local p=game:GetService("PathfindingService") p.EmptyCutoff=0 spawn(function() local torso,humanoid = script.Parent:WaitForChild("Torso"),script.Parent:WaitForChild("Humanoid") torso.Touched:connect(function() wait(math.random()) humanoid.Jump = true end) local walk; walk=function() local target = script.Parent.Targe.Value.Torso local path=p:ComputeSmoothPathAsync(torso.Position,target.Position,500) if path.Status.Name == "Success" then local points = path:GetPointCoordinates() for i,point in pairs (points)do local part,P=workspace:FindPartOnRay(Ray.new(point,Vector3.new(0,-10,0))) if part then point = p points[i] = p end end local distance; for i=1,#points do local point = points[i] humanoid:MoveTo(point) local jump; if point.Y>=torso.Position.Y-1.5 then humanoid.Jump = true jump=humanoid.Changed:connect(function() humanoid.Jump = true end) end local reached=humanoid.MoveToFinished:wait() if jump then jump.Disconnect() end if not reached then return walk() end end else humanoid:MoveTo(torso.CFrame*Vector3.new(0,0,5)) humanoid.MoveToFinish:wait() end return walk() end walk() end)
it is a pathfind script. i use a different model to make my own but this does not work. in the output this error pops up. 00:30:36.619 - Unable to cast Instance to Vector3 00:30:36.619 - Script 'Workspace.Police.Script', Line 25 - local walk 00:30:36.619 - Script 'Workspace.Police.Script', Line 47 00:30:36.620 - Stack End can someone help me please
This isn't the best code in the world, but ignoring that, I think the main issue is these lines (17-20):
if part then point = p points[i] = p end
p
is the PathfindingService (defined in line 1). P
, uppercase, is what you want to replace those lowercase ones with:
if part then point = P points[i] = P end