local Self=script.Parent;
local Humanoid=Self:WaitForChild("Humanoid");
local Torso=Self:WaitForChild("Torso");
local Pathfinding=game:GetService("PathfindingService");
local findplayer = script.Parent.playername.Value
local Player = game.Players:WaitForChild(findplayer)
local MinimumDistance = 500
function FetchCoordinate()
local Target={
Position=Torso.Position;
Distance=MinimumDistance;
}
local pCharacter=Player.Character;
local pTorso=pCharacter:FindFirstChild("Torso");
if(pCharacter and pTorso and Player:DistanceFromCharacter(Torso.Position) < Target.Distance)then
Target.Position=pTorso.Position;
Target.Distance=Player:DistanceFromCharacter(Torso.Position) < Target.Distance;
end
local Coordinates=Pathfinding:ComputeSmoothPathAsync(Torso.Position, Target.Position, MinimumDistance):GetPointCoordinates();
return Coordinates[math.min(#Coordinates, 2)];
end
while true do
Humanoid:MoveTo(FetchCoordinate())
Humanoid.MoveToFinished:wait()
end
this is a pathfind script. this will follow the player whos name is in findplayer. this script will not work the error in the output is. 00:13:40.929 - Workspace.Player.Humanoid.Player's Cop.Main Script:15: attempt to index upvalue 'Player' (a nil value) 00:13:40.930 - Stack Begin 00:13:40.930 - Script 'Workspace.Player.Humanoid.Player's Cop.Main Script', Line 15 - global FetchCoordinate 00:13:40.930 - Script 'Workspace.Player.Humanoid.Player's Cop.Main Script', Line 26 00:13:40.931 - Stack End

3 comments
can you put that in the lua script thing please because its hard to understand it like this
ty for the help it works now
Np