Table bugs after third use

Hello people,
I am making a neat rope system that allows the player to attach a rope to an anchor point that is scattered around the map.

The current system i have works, but the third time i attach a rope, the whole thing breaks.
What do i expect?
Well the thing i expect is that the first time the player attaches a rope, the rope will attach to an attachment inside the player and one inside of the anchor point. And the second time the player want to attach the rope to the second anchor, the old rope is attached to the second, and a new rope will attach from the second to the player.

I have a video of what i mean: video1
A video of my problem: problem

That works fine, but the second i want to attach the rope to the third anchor, nothing happens and the script assumes i have no rope attached to me and attaches one to me.

Snipped of code what i have now:


local currentHookInUse = {} -- these tables are set in the start of the script
local currentRopes = {}

	if #currentRopes == 1 then
				local oldHook:MeshPart = currentHookInUse[1]
				local oldRope:RopeConstraint = currentRopes[1]
				oldRope.Attachment1 = hookAttachment
				oldRope.Parent = oldHook
				table.remove(currentHookInUse,1)
				table.remove(currentRopes,1)
				oldHook = nil
				oldRope = nil
			else
				table.insert(currentHookInUse, hook)
				table.insert(currentRopes, rope)
			end

What is happening?
Thanks for reading

I had to call table.insert(currentHookInUse, hook)
table.insert(currentRopes, rope) again omg im so stupid

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.