Hi all, so I'm currently making an AI follow a player around, as if the AI is a zombie. I'm having one problem with it, and the output is quiet about what's wrong with the script.
For some reason the AI does not follow the player, and the output does not say anything about it. I'm curious on what I've done wrong on my scripts, as it looks fine to me, but I'm not sure if it looks fine to you.
Here's the script in case you need to see if there's anything wrong with it, and the script is not inside the NPC:
-- Pathfinding Service local PathfindingService = game:GetService("PathfindingService") -- Variables local goofyplsm9 = game.Workspace.goofyplsm9 local humanoid = goofyplsm9.Humanoid local humanoidRootPart = goofyplsm9.HumanoidRootPart local player = game.Players.LocalPlayer local character = player.Character -- What goofyplsm9 will follow. local Survivor -- Variables for Survivor. local Survivor = player.character -- Variable to keep track of goofyplsm9's destination. local currentDestination = character if Survivor == true then -- Variables for goofyplsm9's start and goal path. local startingposition = humanoidRootPart.position local goalposition = Survivor -- Goofy needs to find a path to the player. Let's fix that. local path = PathfindingService:FindPathAsync(startingposition, goalposition) local waypoints = path:GetWaypoints() -- If goofyplsm9 reaches the Survivor, it will loop it's seqeunce. for waypointIndex, waypoint in pairs(waypoints) do local waypointPosition = waypoint.Position -- Make the stupid noob move to the survivor humanoid:MoveTo(waypointPosition) end end
goofyplsm9 is the NPC that I'm trying to get to follow me or a player.
I was following an article on the RobloxDev Wiki website and it showed me how to script an AI to move from one point to another point, then repeats itself over and over again. If I made any mistakes making this script from looking at the article, please let me know.
Thanks.