How do I make a rope between two entities?

I’m working on a SWEP, and I’m trying to figure out how to make a rope between the player and a physics prop.

Here’s part of my code:


if SERVER then
                local ent = ents.Create("ropetank")
                
                ent:SetPos(self.Owner:GetShootPos())
                ent:SetAngles(Vector(1,0,0))
                ent:Spawn()
                
                local phys = ent:GetPhysicsObject()
                phys:SetVelocity(self.Owner:GetAimVector() * 1000)
                phys:AddAngleVelocity(Vector(math.random(-1000,1000),math.random(-1000,1000),math.random(-1000,1000)))
                
                self.Owner:RemoveAmmo(1,self.Primary.Ammo)
                
                if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
                    self.Weapon:SendWeaponAnim(ACT_VM_DRAW)
                end
            end

So I need to make an elastic rope between the player and the ropetank entity. Can somebody tell me how to do this?

**[Constraint.Rope

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Constraint.Rope)**

I added what that page told me to, and the SWEP went from giving me an error message to not appearing on the weapons menu at all. Here’s what that part of my code says now:


function SWEP:Think()
    if self.Next < CurTime() then
        if self.Primed == 1 and not self.Owner:KeyDown(IN_ATTACK) then
            self.Weapon:SendWeaponAnim(ACT_VM_THROW)
            self.Primed = 2
            self.Next = CurTime() + .3
        elseif self.Primed == 2 then
            self.Primed = 0
            self.Next = CurTime() + self.Primary.Delay
            
            if SERVER then
                local ent = ents.Create("ropetank")
                
                ent:SetPos(self.Owner:GetShootPos())
                ent:SetAngles(Vector(1,0,0))
                ent:Spawn()
                
                local phys = ent:GetPhysicsObject()
                phys:SetVelocity(self.Owner:GetAimVector() * 1000)
                phys:AddAngleVelocity(Vector(math.random(-1000,1000),math.random(-1000,1000),math.random(-1000,1000)))
                
                
                constraint.Rope( !player, ropetank, 1, 1, Vector( 0, 0, 1 ), Vector( 0, 0, 1 ), 150, 25, 0, 2, cable/rope, 0)
                 end
            end
        end
    end
end

This is my first time using rope constraints, so I’m sure I did something wrong on that line (the underlined one.)