Advertisement
Burkino

labyrinth egg hunt

Apr 21st, 2019
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. local eggspot = workspace.Map.Maze.Generated.SectorPiece.Objectives.Door.Door.Part1
  2. print(eggspot.CFrame)
  3. local makeend = Instance.new("Part",workspace)
  4. makeend.Anchored = true
  5. makeend.CanCollide = false
  6. makeend.CFrame = eggspot.CFrame
  7. makeend.Size = Vector3.new(1,1,1)
  8. makeend.Name = "mazeend"
  9. print("1")
  10. wait(.5)
  11. print("2")
  12. -- Local values to call later
  13.  
  14. local player = game:GetService("Players").LocalPlayer
  15. local human = player.Character.Humanoid
  16. local playerpos = player.Character.Head.Position
  17. local ending = workspace.mazeend.Position
  18. print("before path")
  19. local path = game:GetService("PathfindingService"):FindPathAsync(playerpos,ending)
  20. local points = path:GetWaypoints()
  21. print("locals")
  22.  
  23. --SHOWS WHERE POINTS ARE
  24.  
  25. for i,v in pairs(points) do
  26. local z = Instance.new("Part",workspace)
  27. z.Anchored = true
  28. z.CanCollide = false
  29. z.CFrame = CFrame.new(v.Position)
  30. z.Size = Vector3.new(1,1,1)
  31. z.Name = "PointPath"
  32. end
  33. print("points")
  34.  
  35. -- WALKS TO POINTS
  36.  
  37. if path.Status == Enum.PathStatus.Success then
  38. print("walking")
  39. for i,v in pairs(points) do
  40. human:MoveTo(v.Position)
  41. human.MoveToFinished:wait()
  42. if v.Action == Enum.PathWaypointAction.Jump then
  43. human.Jump = true
  44. end
  45. end
  46. end
  47. print("ending")
  48.  
  49. --Removes point blocks
  50.  
  51. --[[
  52. wait(.1)
  53. for i,v in pairs(game.Workspace:GetChildren()) do
  54. if v.Name == "PointPath" then
  55. v:Destroy()
  56. wait()
  57. end
  58. game:GetService("Workspace").mazeend:Destroy()
  59. end
  60. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement