Advertisement
TheUnknownDiscord

Following dummy

Feb 20th, 2022 (edited)
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.86 KB | None | 0 0
  1. local char = Instance.new("Model" , script)
  2. char.Name = "Pathfinding Dummy"
  3. local hed = Instance.new("Part", char)
  4. hed.Name = "Head"
  5. hed.Size = Vector3.new(1,1,1)
  6. local ro = Instance.new("RemoteEvent",owner.PlayerGui)
  7. ro.Name = "The"
  8. local dead = false
  9. owner.Character.Head.Mesh:Clone().Parent = hed
  10. local dc = Instance.new("Decal",hed)
  11. dc.Face = "Front"
  12. dc.Texture = "rbxassetid://2773283257"
  13. local tors = Instance.new("Part", char)
  14. tors.Name = "Torso"
  15. tors.Size = Vector3.new(2,2,1)
  16. local hedw = Instance.new("Motor6D", tors)
  17. hedw.Part0 = tors
  18. hedw.Part1 = hed
  19. hedw.Name = "Neck"
  20. hedw.C0 = CFrame.new(0,0.5,0)
  21. hedw.C1 = CFrame.new(0,-1,0)
  22. local p2 = Instance.new("Part", char)
  23. p2.Name = "HumanoidRootPart"
  24. p2.Size = Vector3.new(2,2,1)
  25. p2.Material = "SmoothPlastic"
  26. p2.Transparency = 1
  27. p2.CanCollide = false
  28. local fake = p2
  29. local ra = Instance.new("Part", char)
  30. ra.Name = "Right Arm"
  31. ra.CanCollide = false
  32. ra.Size = Vector3.new(1,2,1)
  33. local la = Instance.new("Part", char)
  34. la.Name = "Left Arm"
  35. la.CanCollide = false
  36. la.Size = Vector3.new(1,2,1)
  37. local ll = Instance.new("Part", char)
  38. ll.Name = "Left Leg"
  39. ll.CanCollide = false
  40. ll.Size = Vector3.new(1,2,1)
  41. local rl = Instance.new("Part", char)
  42. rl.Name = "Right Leg"
  43. rl.CanCollide = false
  44. rl.Size = Vector3.new(1,2,1)
  45. local torswe = Instance.new("Motor6D", fake)
  46. torswe.Part0 = fake
  47. torswe.Part1 = tors
  48. torswe.Name = "Root Joint"
  49. torswe.C0 = owner.Character.HumanoidRootPart["RootJoint"].C0
  50. torswe.C1 = owner.Character.HumanoidRootPart["RootJoint"].C1
  51. local a = Instance.new("Motor6D" , tors)
  52. a.Name = "Right Shoulder"
  53. a.Part0 = tors
  54. a.Part1 = ra
  55. a.C0 = owner.Character.Torso["Right Shoulder"].C0
  56. a.C1 = owner.Character.Torso["Right Shoulder"].C1
  57. local aaa = Instance.new("Motor6D" , tors)
  58. aaa.Name = "Left Shoulder"
  59. aaa.Part0 = tors
  60. aaa.Part1 = la
  61. aaa.C0 = owner.Character.Torso["Left Shoulder"].C0
  62. aaa.C1 = owner.Character.Torso["Left Shoulder"].C1
  63. local aa = Instance.new("Motor6D" , tors)
  64. aa.Name = "Left Hip"
  65. aa.Part0 = tors
  66. aa.Part1 = ll
  67. aa.C0 = owner.Character.Torso["Left Hip"].C0
  68. aa.C1 = owner.Character.Torso["Left Hip"].C1
  69. local aaaa = Instance.new("Motor6D" , tors)
  70. aaaa.Name = "Right Hip"
  71. aaaa.Part0 = tors
  72. aaaa.Part1 = rl
  73. aaaa.C0 = owner.Character.Torso["Right Hip"].C0
  74. aaaa.C1 = owner.Character.Torso["Right Hip"].C1
  75. local scri1 = Instance.new("Script" , char)
  76. scri1.Name = "Health"
  77. local idle = false
  78. local scri3 = Instance.new("Script" , char)
  79. scri3.Name = "Sound"
  80. char.PrimaryPart = fake
  81. owner.Character.Archivable = true
  82. local hum = Instance.new("Humanoid")
  83. hum.Parent = char
  84. hum.Name = "Humanoid"
  85. hum.RequiresNeck = false
  86. hum.DisplayName = "Pathfinding Dummy"
  87. hum.MaxHealth = 100
  88. hum.Health = 100
  89. hum.BreakJointsOnDeath = false
  90. hum.AutoJumpEnabled = true
  91. local object = Instance.new("ObjectValue", owner.PlayerGui)
  92. object.Value = char
  93. object.Name = "Model"
  94. local bc = Instance.new("BodyColors",char)
  95. bc.HeadColor3 = Color3.new(242/255, 243/255, 243/255)
  96. bc.RightArmColor3 = Color3.new(242/255, 243/255, 243/255)
  97. bc.LeftArmColor3 = Color3.new(242/255, 243/255, 243/255)
  98. bc.LeftLegColor3 = Color3.new(253/255, 166/255, 53/255)
  99. bc.RightLegColor3 = Color3.new(253/255, 166/255, 53/255)
  100. bc.TorsoColor3 = Color3.new(253/255, 166/255, 53/255)
  101. for i,v in pairs(char:GetDescendants()) do
  102. if v:IsA("Part") then
  103. v:SetNetworkOwner(owner)
  104. end
  105. end
  106. wait()
  107. p2.CFrame = owner.Character.Head.CFrame
  108. Instance.new("Animator",hum).Name = "Animator"
  109. function onDied()
  110. dead = true
  111. for i, v in pairs (hum:GetPlayingAnimationTracks()) do
  112. v:Stop()
  113. end
  114. local ss = Instance.new("Sound",hed)
  115. local sounds = {"4755480391","4523373375","2618158728","5525467333","856379539","5438872876"}
  116. local rand = sounds[math.random(1,6)]
  117. ss.SoundId = "rbxassetid://"..rand
  118. ss.Volume = 1.5
  119. ss:Play()
  120. game:GetService("Debris"):AddItem(char,game:GetService("Players").RespawnTime)
  121. end
  122. local animationTrack = hum.Animator:LoadAnimation(owner.Character.Animate.run.RunAnim)
  123. animationTrack.Looped = true
  124. animationTrack.Priority = Enum.AnimationPriority.Movement
  125. local animationTrack4 = hum.Animator:LoadAnimation(owner.Character.Animate.idle.Animation1)
  126. animationTrack4.Looped = true
  127. animationTrack4.Priority = Enum.AnimationPriority.Idle
  128. animationTrack4:Play()
  129. local animationTrack3 = hum.Animator:LoadAnimation(owner.Character.Animate.fall.FallAnim)
  130. animationTrack3.Looped = true
  131. animationTrack3.Priority = Enum.AnimationPriority.Movement
  132. local animationTrack2 = hum.Animator:LoadAnimation(owner.Character.Animate.jump.JumpAnim)
  133. animationTrack2.Priority = Enum.AnimationPriority.Movement
  134. animationTrack:Play()
  135. function jump()
  136. animationTrack2:Play()
  137. animationTrack:Stop()
  138. end
  139. function stopf(ol,ne)
  140. if ne == Enum.HumanoidStateType.Landed or ol == Enum.HumanoidStateType.Freefall then
  141. animationTrack3:Stop()
  142. if not idle then
  143. animationTrack:Play()
  144. end
  145. elseif ne == Enum.HumanoidStateType.Freefall then
  146. animationTrack2:Stop()
  147. animationTrack3:Play()
  148. end
  149. end
  150. hum.Died:Connect(onDied)
  151. hum.StateChanged:Connect(stopf)
  152. hum.Jumping:Connect(jump)
  153. coroutine.wrap(function()
  154. while task.wait() do
  155. if hum.Sit == true then
  156. hum.Jump = true
  157. end
  158. animationTrack:AdjustSpeed(char:FindFirstChildWhichIsA("Part").Velocity.Magnitude / hum.WalkSpeed)
  159. if char:FindFirstChildWhichIsA("Part").Velocity.Magnitude == 0 then
  160. animationTrack:Stop()
  161. idle = true
  162. else
  163. if idle and not dead then
  164. idle = false
  165. animationTrack:Play()
  166. end
  167. end
  168. end
  169. end)()
  170. for i,v in pairs(owner.Character.Animate:GetChildren()) do
  171. local cl = v:Clone()
  172. cl.Parent = scri2
  173. end
  174. NLS([[
  175. local model = owner.PlayerGui.Model.Value
  176. found = true
  177. local lastknownposition
  178. humanoid = model.Humanoid
  179. roombas = {model}
  180. part = model.Torso
  181. lastknownposition = Vector3.new()
  182. function wallcheck(who,mod)
  183. coroutine.wrap(function()
  184. pcall(function()
  185. iforgor = {}
  186. local raycastParams = RaycastParams.new()
  187. raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
  188. raycastParams.FilterDescendantsInstances = {roombas,who,mod}
  189. raycastParams.IgnoreWater = true
  190. local result = workspace:Raycast(part.Position + Vector3.new(0,-0.5,0), CFrame.new(part.Position,who.Position).lookVector * (part.Position - who.Position).Magnitude, raycastParams)
  191. if result then
  192. table.insert(iforgor,mod)
  193. else
  194. lastknownposition = who.CFrame * CFrame.new(0,0,2)
  195. end
  196. end)
  197. end)()
  198. return iforgor
  199. end
  200. function move(destination,wher)
  201. coroutine.wrap(function()
  202. if wher ~= false then
  203. local PathfindingService = game:GetService("PathfindingService")
  204. local path = PathfindingService:CreatePath({
  205. AgentRadius = 7,
  206. AgentHeight = 5,
  207. AgentCanJump = true,
  208. WaypointSpacing = 0.75,
  209. Costs = {
  210. }
  211. })
  212. local waypoints
  213. local nextWaypointIndex
  214. local reachedConnection
  215. local blockedConnection
  216. local success, errorMessage = pcall(function()
  217. path:ComputeAsync(part.Position, destination)
  218. end)
  219. if success and path.Status == Enum.PathStatus.Success then
  220. waypoints = path:GetWaypoints()
  221. blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex)
  222. if blockedWaypointIndex >= nextWaypointIndex then
  223. blockedConnection:Disconnect()
  224. move(destination)
  225. end
  226. end)
  227. if not reachedConnection then
  228. reachedConnection = humanoid.MoveToFinished:Connect(function(reached)
  229. if reached and nextWaypointIndex < #waypoints then
  230. nextWaypointIndex = nextWaypointIndex + 1
  231. if waypoints[nextWaypointIndex].Action == Enum.PathWaypointAction.Walk then
  232. humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
  233. else
  234. humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
  235. coroutine.wrap(function()
  236. wait(0.125)
  237. humanoid.Jump = true
  238. end)()
  239. end
  240. elseif reached and nextWaypointIndex >= #waypoints then
  241. found = true
  242. reachedConnection:Disconnect()
  243. blockedConnection:Disconnect()
  244. end
  245. end)
  246. end
  247. nextWaypointIndex = 1
  248. humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
  249. else
  250. move(destination,true)
  251. end
  252. else
  253. humanoid:MoveTo(destination)
  254. end
  255. end)()
  256. end
  257. local function findNearestTorso(pos)
  258. local list = game.Workspace:GetChildren()
  259. local torso = nil
  260. local dist = 75
  261. local temp = nil
  262. local human = nil
  263. local temp2 = nil
  264. for x = 1, #list do
  265. temp2 = list[x]
  266. if (temp2.className == "Model") and (temp2 ~= model) then
  267. temp = temp2:findFirstChild("Torso")
  268. human = temp2:findFirstChild("Humanoid")
  269. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  270. if (temp.Position - pos).magnitude < dist then
  271. torso = temp
  272. mod = temp2
  273. dist = (temp.Position - pos).magnitude
  274. end
  275. end
  276. end
  277. end
  278. return torso, mod
  279. end
  280. while true do
  281. local torso, mod = findNearestTorso(part.Position)
  282. local iforgor = wallcheck(torso,mod)
  283. if table.find(iforgor,mod) and torso ~= nil then
  284. move(lastknownposition.Position)
  285. found = false
  286. repeat
  287. wait()
  288. until found == true
  289. elseif torso ~= nil then
  290. local pos = torso.CFrame * CFrame.new(0,0,2)
  291. move(pos.Position,false)
  292. end
  293. task.wait()
  294. end
  295. ]],owner.PlayerGui)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement