Rhysical

a project maybe

Oct 20th, 2023
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local total = 1
  3. local PathFindParts = {}
  4.  
  5. local function part()
  6. local cube = Instance.new("Part")
  7. cube.Size = Vector3.new(1, 1, 1)
  8. cube.Anchored = true
  9. cube.CanCollide = false
  10. cube.Name = "PathFindCube_" .. total
  11. cube.Position = player.Character.HumanoidRootPart.Position + Vector3.new(0, 2, 0)
  12. cube.BrickColor = BrickColor.new("Bright red")
  13. cube.Parent = workspace
  14. table.insert(PathFindParts, cube.Name)
  15. total = total + 1
  16. print("Total: " .. total)
  17. end
  18.  
  19. local function removeAllParts()
  20. for _, part in ipairs(workspace:GetChildren()) do
  21. if part:IsA("Part") and part.Name:match("^PathFindCube_") then
  22. part:Destroy()
  23. end
  24. end
  25. PathFindParts = {}
  26. end
  27.  
  28. local function pathfindToParts()
  29. local character = player.Character
  30. if character then
  31. local humanoid = character:FindFirstChild("Humanoid")
  32. if humanoid then
  33. for _, partName in ipairs(PathFindParts) do
  34. local part = workspace:FindFirstChild(partName)
  35. if part then
  36. humanoid:MoveTo(part.Position)
  37. wait(humanoid.WalkToPoint.magnitude / humanoid.WalkSpeed)
  38. end
  39. end
  40. local firstPartName = PathFindParts[1]
  41. local firstPart = workspace:FindFirstChild(firstPartName)
  42. if firstPart then
  43. humanoid:MoveTo(firstPart.Position)
  44. end
  45. end
  46. end
  47. end
  48.  
  49. local Library = loadstring(game:HttpGet("https://raw.githubusercontent.com/xHeptc/Kavo-UI-Library/main/source.lua"))()
  50. local Window = Library.CreateLib("TITLE", "DarkTheme")
  51. local Section = Window:NewSection("Section Name")
  52. Section:NewButton("Create Part", "Creates a new part", function()
  53. part()
  54. end)
  55. Section:NewButton("Remove All Parts", "Removes all created parts", function()
  56. removeAllParts()
  57. end)
  58. Section:NewButton("Pathfind to Parts", "Pathfind to all parts and return", function()
  59. pathfindToParts()
  60. end)
Advertisement
Add Comment
Please, Sign In to add comment