Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Please help me fix this follow script?

Asked by
Xl5Xl5 65
9 years ago

How would I get the NPC to follow the player when Choice4 is selected? Hierarchy of where the script is. NPC>Head>Dialog>My script is here>Choice4

Please can someone help me with this, the NPC doesn't follow when Choice4 is selected. Please help! thanks!


script.Parent.DialogChoiceSelected:connect(function(player,choice) local humanoid = player.Character:findFirstChild("Humanoid") if not humanoid then return end --End the function if the humanoid isn't found local stats = player:FindFirstChild('leaderstats') if not stats then return end local rep = stats:FindFirstChild('Reputation') if not rep then return end if choice.Name == "Choice1" then --If the DialogChoice's name is Die then do the following wait(1) rep.Value = rep.Value - 1 elseif choice.Name == "Choice2" then wait(1) --Make the player jump. -- humanoid.Jump = true rep.Value = rep.Value + 1 elseif choice.Name == "Choice3" then wait(1) rep.Value = rep.Value - 2 local pathfinding = game:GetService("PathfindingService") function getDistanceFrom(part1, part2, distance) if (part1.Position - part2.Position).magnitude < distance then return true end return false end elseif choice.Name == "Choice4" then while true do wait(0.8) -- edit this to your desire, this is how much he changes his path local char = player.Character local path = pathfinding:ComputeSmoothPathAsync(NPC.Torso.Position, char.Torso.Position) for i, v in pairs(path:GetPointCoordinates()) do -- forgot the name of that method, could be wrong NPC.Humanoid:MoveTo(v) NPC.Humanoid.MoveToFinished:wait() end end end end end)

Answer this question