Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local total = 1
- local PathFindParts = {}
- local function part()
- local cube = Instance.new("Part")
- cube.Size = Vector3.new(1, 1, 1)
- cube.Anchored = true
- cube.CanCollide = false
- cube.Name = "PathFindCube_" .. total
- cube.Position = player.Character.HumanoidRootPart.Position + Vector3.new(0, 2, 0)
- cube.BrickColor = BrickColor.new("Bright red")
- cube.Parent = workspace
- table.insert(PathFindParts, cube.Name)
- total = total + 1
- print("Total: " .. total)
- end
- local function removeAllParts()
- for _, part in ipairs(workspace:GetChildren()) do
- if part:IsA("Part") and part.Name:match("^PathFindCube_") then
- part:Destroy()
- end
- end
- PathFindParts = {}
- end
- local function pathfindToParts()
- local character = player.Character
- if character then
- local humanoid = character:FindFirstChild("Humanoid")
- if humanoid then
- for _, partName in ipairs(PathFindParts) do
- local part = workspace:FindFirstChild(partName)
- if part then
- humanoid:MoveTo(part.Position)
- wait(humanoid.WalkToPoint.magnitude / humanoid.WalkSpeed)
- end
- end
- local firstPartName = PathFindParts[1]
- local firstPart = workspace:FindFirstChild(firstPartName)
- if firstPart then
- humanoid:MoveTo(firstPart.Position)
- end
- end
- end
- end
- local Library = loadstring(game:HttpGet("https://raw.githubusercontent.com/xHeptc/Kavo-UI-Library/main/source.lua"))()
- local Window = Library.CreateLib("TITLE", "DarkTheme")
- local Section = Window:NewSection("Section Name")
- Section:NewButton("Create Part", "Creates a new part", function()
- part()
- end)
- Section:NewButton("Remove All Parts", "Removes all created parts", function()
- removeAllParts()
- end)
- Section:NewButton("Pathfind to Parts", "Pathfind to all parts and return", function()
- pathfindToParts()
- end)
Advertisement
Add Comment
Please, Sign In to add comment