Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ___ ___ ___ _
- --| . || __>| . | ___ ___ ._ _ _ ___ _ _ / |
- --| | || _> | |/ . |<_> || ' ' |/ ._>| '_>| |
- --`___'|___>|_|_|\_. |<___||_|_|_|\___.|_| |_|
- -- <___'
- -- -> YT: OEAgamer1
- local travelInterval = 4
- local velocityCap = 30
- local angularVelocityCap = 3
- local shouldRemoveTargets = true
- local container = script.Parent
- local mover = container:FindFirstChild("Platform")
- local positionController = mover:FindFirstChild("AlignPosition")
- local orientationController = mover:FindFirstChild("AlignOrientation")
- local pathPoints = {}
- repeat
- local nextTarget = nil
- local smallestIndex = math.huge
- for _, element in ipairs(container:GetChildren()) do
- if element:IsA("BasePart") then
- local parts = string.split(element.Name, " ")
- local prefix, number = parts[1], tonumber(parts[2])
- if string.lower(prefix) == "destination" and number and number < smallestIndex then
- smallestIndex = number
- nextTarget = element
- end
- end
- end
- if nextTarget then
- table.insert(pathPoints, nextTarget.CFrame)
- if shouldRemoveTargets then
- nextTarget:Destroy()
- else
- nextTarget.Name = "Target"
- end
- end
- until not nextTarget
- positionController.MaxVelocity = velocityCap
- orientationController.MaxAngularVelocity = angularVelocityCap
- positionController.Position = pathPoints[1].Position
- orientationController.CFrame = pathPoints[1].Rotation
- mover.Anchored = false
- while true do
- for i = 1, #pathPoints do
- local frame = pathPoints[i]
- positionController.Position = frame.Position
- orientationController.CFrame = frame.Rotation
- task.wait(travelInterval)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement