For pairs issues

I’m making an attack where when you’re hit once you cannot be hit again but it’ll still do damage, and on the final hit it deletes a weld and does the knockback and ragdoll (not the issue) the issue is deleting the weld. To delete the weld I iterate through all descendants of the character (V) and check for the weld

	for I,V:Model in ipairs(HitPeople[Character]) do
			local HitHumanoid = V:FindFirstChildOfClass("Humanoid")
			local HitRoot = V:FindFirstChild("HumanoidRootPart")
			local VData = Modules.Manager:Retrieve(V)
			
			Modules.Functions.Damage(V, DamageData, Character)
			local P = {
				["Volume"] = 0.2,
				["Parent"] = V.PrimaryPart,
				["RollOffMode"] = Enum.RollOffMode.Linear
			}
			SoundService.PlaySound(HitSound, P, HitSound.TimeLength)
			
			local ACData = {
				V,
				2,
				true,
				{Offset = 5, Height = 0, Distance = 4}
			}
			if VData.Status.AirCombo then
				Modules.Functions.AirCombo(Character, ACData)
			end
			
			if Arg == "Final" then
				table.clear(HitPeople[Character])
				print("Finalizing Hit")
				local KBData = {
					true,
					110,
					80
				}
				for Index,weldthing in ipairs(V:GetDescendants()) do
					if weldthing:IsA("WeldConstraint") then
						game:GetService("Debris"):AddItem(weldthing)
					end
				end
				if Data.Status.AirCombo then
					Data.Status.AirCombo = false
					Modules.Functions.RemoveAirCombo(Character)
				end
				Modules.RagdollService:RagdollCharacter(V, 2)
				Modules.Functions.Knockback(V, KBData, Character)
			end
		end 

Try this and see what the output is:

				for Index,weldthing in ipairs(V:GetDescendants()) do
                print(Index, "    weldthing name = ", weldthing.Name)
					if weldthing:IsA("WeldConstraint") then
						game:GetService("Debris"):AddItem(weldthing)
					end
				end
1 Like

it finds the weld, but doesn’t delete it… am i stupid?

Is it a Weld or a WeldConstraint. They are two different instances.

constraint, when i put in print weld name it prints the weld name, it is a weld constraint, but for some reason it doesn’t get deleted?

if weldthing:IsA("WeldConstraint") then
Could you do
if weldthing.Name == "WeldConstraint" then

Fixed it!

for Ind,Value in ipairs(V:GetDescendants()) do
					if Value.Name == "ThirdStrikeWeld" then
						game:GetService("Debris"):AddItem(Value,0)
						task.delay(0.4, function()
						HitPeople[Character] = nil
						end)
					end
				end

remember to mark solution yourself so this topic can close

2 Likes

So basically the same thing I recommended… :slightly_smiling_face:

1 Like

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