How to detect if a for loop is done?

Hello guys am making a combat system which when you kick the player he falls and ragdoll
the problem is when i am making him get up i have to delete each BallSocket but i made it in the loop so i dont know how to delete it when the loop is done

for index,joint in pairs(Kick.Parent:GetDescendants()) do
				if joint:IsA("Motor6D") then
				local socket = Instance.new("BallSocketConstraint")
					local a1 = Instance.new("Attachment")
					local a2 = Instance.new("Attachment")
					a1.Parent = joint.Part0
					a2.Parent = joint.Part1
					socket.Parent = joint.Parent
					socket.Attachment0 = a1
					socket.Attachment1 = a2
					a1.CFrame = joint.C0
					a2.CFrame = joint.C1
					socket.LimitsEnabled = true
					socket.TwistLimitsEnabled = true
					joint.Enabled = false
					
					task.wait(4)
					Kick.Parent:FindFirstChild("Humanoid"):ChangeState(Enum.HumanoidStateType.GettingUp)
					joint.Enabled = true
					socket:Destroy()
					a1:Destroy()
					a2:Destroy()
				end
			
			end

get the number of descendants you are looping through, everytime you go through the loop add 1 to a value, when that value is equal to the number of descendants its done.

Or in your code if you just want to wait till the for loop is over then well:

for index,joint in pairs(Kick.Parent:GetDescendants()) do
				if joint:IsA("Motor6D") then
				local socket = Instance.new("BallSocketConstraint")
					local a1 = Instance.new("Attachment")
					local a2 = Instance.new("Attachment")
					a1.Parent = joint.Part0
					a2.Parent = joint.Part1
					socket.Parent = joint.Parent
					socket.Attachment0 = a1
					socket.Attachment1 = a2
					a1.CFrame = joint.C0
					a2.CFrame = joint.C1
					socket.LimitsEnabled = true
					socket.TwistLimitsEnabled = true
					joint.Enabled = false
					
					task.wait(4)
					Kick.Parent:FindFirstChild("Humanoid"):ChangeState(Enum.HumanoidStateType.GettingUp)
					joint.Enabled = true
					socket:Destroy()
					a1:Destroy()
					a2:Destroy()
				end
			
			end
print("For loop over")

i mean i want this part

task.wait(4)
					Kick.Parent:FindFirstChild("Humanoid"):ChangeState(Enum.HumanoidStateType.GettingUp)
					joint.Enabled = true
					socket:Destroy()
					a1:Destroy()
					a2:Destroy()

when the loop is done

well right after the a:destroy() part just like set a value to true and boom now you know its done.