Zipline Script only working once

Hello everyone, I am making a simple zipline script, but it only works the first time, then doesnt work at all. Here is the script:

local CollectionService = game:GetService("CollectionService")
local TweenService      = game:GetService("TweenService")
local RIDE_DURATION   = 2
local DISABLED_JUMP   = 0
local DISABLED_SPEED  = 0
local NORMAL_JUMP     = 35 
local NORMAL_SPEED    = 16

local function connectZiplineEnd(partA, partB)
    local promptA = partA:WaitForChild("ProximityPrompt")
    local riding  = {}

    promptA.Triggered:Connect(function(player)
        if riding[player] then return end
        local char = player.Character
        if not (char and char:FindFirstChild("HumanoidRootPart")) then return end

        local humanoid = char:FindFirstChild("Humanoid")
        local root     = char.HumanoidRootPart
        riding[player] = true

        humanoid.JumpPower = DISABLED_JUMP
        humanoid.WalkSpeed = DISABLED_SPEED

        local info  = TweenInfo.new(RIDE_DURATION, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
        local goal  = { Position = partB.Position }
        local tween = TweenService:Create(root, info, goal)
        tween:Play()

        tween.Completed:Connect(function()
            humanoid.JumpPower = NORMAL_JUMP
            humanoid.WalkSpeed = NORMAL_SPEED
            riding[player] = nil
        end)
    end)
end

for _, model in ipairs(CollectionService:GetTagged(ZIPLINE_TAG)) do
    local endA = model:WaitForChild("EndA")
    local endB = model:WaitForChild("EndB")

    connectZiplineEnd(endA, endB)
    connectZiplineEnd(endB, endA)
end

Try printing your variable checks.
For example

        print(riding{player})
        if riding[player] then return end

It tells you what the variable is before each check so you can troubleshoot the issue.

Could this be because of HRP ownership or something?

I’m not sure.
If you put prints before each check or after each function it’ll show you if it’s a script issue though.

local function connectZiplineEnd(partA, partB)
    print("Zipline connected")
    local promptA = partA:WaitForChild("ProximityPrompt")
    local riding  = {}    -- is this resetting 'riding' to something unexpected?

    promptA.Triggered:Connect(function(player)
        print(riding{player})  -- also lets you know if the prompt has been triggered or not
        if riding[player] then return end
        -- rest of code

Yeah so a couple of things I would like to point out. Make sure for each return you use a print or warn before/after it, as this will give you a clear indication of what really is going wrong.
Furthermore I recommend putting the riding variable outside of the function’s scope. This would also disallow you to ride one and while you are riding that one you ride the other.
Also I recommend using :Once on the tween rather than :Completed, it should not matter too much, but basically it cleans itself up.

Also is this issue cased by the proximity prompt not being triggerable? Also please do put prints at basically all steps.