Hello! I need help making a script where if an npc with the name NPC touches a part, it will do this:
local ServerStorage = game:GetService("ServerStorage") 3 local SimplePath = require(ServerStorage.SimplePath) 4 5 --Define npc 6 local Dummy = workspace.Dummy 7 8 -- Define a part called "Goal" 9 local Goal = workspace.Goal 10 11 --Create a new Path using the Dummy 12 local Path = SimplePath.new(Dummy) 13 14 --Helps to visualize the path 15 Path.Visualize = true 16 17 --Dummy knows to compute path again if something blocks the path 18 Path.Blocked:Connect(function() 19 Path:Run(Goal) 20 end) 21 22 --If the position of Goal changes at the next waypoint, compute path again 23 Path.WaypointReached:Connect(function() 24 Path:Run(Goal) 25 end) 26 27 --Dummmy knows to compute path again if an error occurs 28 Path.Error:Connect(function(errorType) 29 Path:Run(Goal) 30 end) 31 32 Path:Run(Goal)