Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TweenService = game:GetService("TweenService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Parts = script.Parent:WaitForChild("Parts")
- local RWeldPart = ReplicatedStorage.RWeldPart
- local RRoadPart = ReplicatedStorage.RRoadPart
- local WeldPart = Parts.WeldPart
- local RoadPart = Parts.RoadPart
- local EndPart = script.Parent.EndPart
- local StartPart = script.Parent.StartPart
- local Tweenfo = TweenInfo.new(
- 3,
- Enum.EasingStyle.Linear,
- Enum.EasingDirection.In,
- 0,
- false,
- 0
- )
- local goals = {CFrame = EndPart.CFrame}
- for _,part0 in pairs(Parts:GetChildren()) do
- if part0.Name == "RoadPart" then
- local WeldConstraint = Instance.new("WeldConstraint")
- WeldConstraint.Part0 = part0
- WeldConstraint.Part1 = Parts.WeldPart
- WeldConstraint.Parent = WeldConstraint.Part0
- end
- end
- local newTween = TweenService:Create(Parts:FindFirstChild("WeldPart"), Tweenfo, goals)
- newTween:Play()
- while wait() do
- for _,v in pairs(Parts:GetChildren()) do
- if v.Position.z >= EndPart.Position.z then
- if v.Name == "RoadPart" then
- local CF = v.CFrame
- v:Destroy()
- local newRP = RRoadPart:Clone()
- newRP.Parent = Parts
- newRP.Name = "RoadPart"
- newRP.CFrame = CF - Vector3.new(0,0,9*(#Parts:GetChildren()-1))
- newRP.Color = Color3.new(math.random(0,250), math.random(0,250), math.random(0,250))
- newRP.Anchored = false
- local WeldConstraint = Instance.new("WeldConstraint")
- WeldConstraint.Part0 = newRP
- WeldConstraint.Part1 = Parts.WeldPart
- WeldConstraint.Parent = WeldConstraint.Part0
- elseif v.Name == "WeldPart" then
- local newWP = RWeldPart:Clone()
- newWP.Parent = Parts
- newWP.Name = "WeldPart"
- newWP.CFrame = StartPart.CFrame
- v:Destroy()
- for _,part0 in pairs(Parts:GetChildren()) do
- if part0.Name == "RoadPart" then
- local WeldConstraint = Instance.new("WeldConstraint")
- WeldConstraint.Part0 = part0
- WeldConstraint.Part1 = newWP
- WeldConstraint.Parent = WeldConstraint.Part0
- end
- end
- newTween = TweenService:Create(Parts:FindFirstChild("WeldPart"), Tweenfo, goals)
- newTween:Play()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement