Hello there,
I recently tried to make a zipline, it’s 99% done but I have one error which I’m getting very sick of!
The issue:
As you see, once I’m on the zipline the zipline will repeat forever.
Workspace:
Seat Script:
seat = script.Parent
anim = seat.Animation
proximityPrompt = script.Parent.Parent.Parent.Parent.ProximityPrompt.ProxPromptPart.ProximityPrompt
function Added(Descendant)
if (Descendant.ClassName == "Weld") then
local Humanoid = Descendant.Part1.Parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
local plr = Humanoid
game.Workspace.ZiplineCode.bindableEvent.ziplineEvent:Fire(plr)
Animation = Humanoid:LoadAnimation(anim)
Animation:Play()
end
end
end
function Removing(Descendant)
if Animation ~= nil then
Animation:Stop()
Animation:Remove()
end
end
seat.ChildAdded:Connect(Added)
seat.ChildRemoved:Connect(Removing)
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
proximityPrompt.Enabled = false
else
proximityPrompt.Enabled = true
end
end)
ProximityPrompt Script:
script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
local hum = plr.Character:WaitForChild("Humanoid")
script.Parent.Parent.Parent.MainSeat.ZiplineSeat.Seat:Sit(hum)
end)
Tweening zipline script:
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Destinations = game.Workspace.ZiplineCode.DestinationNavigation
local AIZipline = game.Workspace.ZiplineStructure.MainSeat.ZiplineSeat
local NewPoint = 1
local Speed = 25
local debounce = false
AIZipline.PrimaryPart = AIZipline.Center
AIZipline:SetPrimaryPartCFrame(AIZipline.Center.CFrame)
function GetTime(Distance, Speed)
local Time = Distance / Speed
return Time
end
function WeldAIZipline()
for i = 1, #AIZipline:GetChildren() do
if AIZipline:GetChildren()[i] ~= AIZipline.PrimaryPart then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = AIZipline:GetChildren()[i]
Weld.Part1 = AIZipline.PrimaryPart
Weld.Parent = AIZipline.PrimaryPart
AIZipline:GetChildren()[i].Anchored = false
end
end
end
function AutoZipline()
NewPoint += 1
if not Destinations:FindFirstChild(""..NewPoint) then
if game.Workspace.ZiplineStructure.MainSeat.ZiplineSeat.Seat:FindFirstChild("SeatWeld") then
local hum = game.Workspace.ZiplineStructure.MainSeat.ZiplineSeat.Seat.SeatWeld.Part1.Parent:WaitForChild("Humanoid")
hum.Jump = true
warn("At end, we jump. Source: 'Humanoid'")
end
wait(2)
NewPoint = 1
AIZipline.PrimaryPart.CFrame = Destinations:FindFirstChild("1").CFrame
wait(2)
end
local NextPoint = Destinations[""..NewPoint]
local Distance = (AIZipline.PrimaryPart.Position - NextPoint.Position).Magnitude
local Time = GetTime(Distance, Speed)
warn(Time.." time. Source: '"..script.Name.."'")
local TweenInformation = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local Tween = TweenService:Create(AIZipline.PrimaryPart, TweenInformation, {CFrame = NextPoint.CFrame})
Tween:Play()
Tween.Completed:Wait()
AutoZipline()
end
game.Workspace.ZiplineCode.bindableEvent.ziplineEvent.Event:Connect(function()
warn("Received signal")
WeldAIZipline()
warn("Welded AI Zipline")
AutoZipline()
warn("Tweening AI Zipline")
end)
Any help is very appreciated, thank you!
