Hello, I'm making a action game and i'm making the AI for the enemies. However whenever i run the script I get this error:
Workspace.Skeleton.Control:3: attempt to index field 'LocalPlayer' (a nil value)
This is the script:
while wait() do local player = game.Players.LocalPlayer.Character local path = game:GetService("PathfindingService"):ComputeRawPathAsync(script.Parent.HumanoidRootPart.Position,player.HumanoidRootPart.Position, 200) if path.Status == Enum.PathStatus.Success then local pts = path:GetPointCoordinates() if #pts < 3 then script.Parent.Humanoid:MoveTo(player.HumanoidRootPart.Position) else script.Parent.Humanoid:MoveTo(pts[3]) end else script.Parent.Humanoid:MoveTo(player.HumanoidRootPart.Position) end end
Help would be much appreciated :)
You are trying to find the local player in a normal script. LocalPlayer can only be accessed in a local script. Hope this helps.