So, I have a script where when an npc touched a part then it will stop a animation. But, when I put a part.touched event then the animation doesn’t play at all in this script I got rit of the touched event btw
local PathFindingService = game:GetService(“PathfindingService”)
local npc = script.Parent
local humanoid = npc:WaitForChild(“Humanoid”)
local GoalPart = game.Workspace:WaitForChild(“GoalPart”)
local success, errorMessage = pcall(function()
path:ComputeAsync(npc.PrimaryPart.Position, GoalPart.Position)
local animation = script:WaitForChild(“Walk”)
local npc = script.Parent:WaitForChild(“Humanoid”)
local model = npc:LoadAnimation(animation)
local goalPart = game.Workspace:WaitForChild(“GoalPart”)
model:Play()
end)
if success then
for _,waypoint in pairs(path:GetWaypoints()) do
local part = Instance.new(“Part”)
part.Material = “Neon”
part.Anchored = true
part.CanCollide = false
part.Shape = “Ball”
part.Position = waypoint.Position
part.Parent = game.Workspace
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
end
else
warn(“The path has not worked”, errorMessage)
end
He just typed in “Char limit” because devforum requires a character limit for replies.
Also, I’m not entirely sure why you’re using a part’s Touched event to know when to play an animation. I’m assuming the part you’re using is the ball you create at the waypoint location, but a better way to handle it is to use the Humanoid.MoveToFinished event. Also, I’d make sure that the animation you want to play has the priority set properly so it can play over the walk and idle animations.
So I found the solution myself I detected if the move was finished with a if statement and if it was at the correct point then the animation would stop