Help with removing RightGrip from Character

Hello, so basically a weld called ‘RightGrip’ keeps on messing up my tool animation. When I attempt to remove it through a script, it produced this warning:
image
The Script:

for i, weld in pairs(script.Parent:GetDescendants()) do
	if weld:IsA("Weld") and weld.Name == "RightGrip" then
		weld:Destroy()
	end
end

script.Parent.DescendantAdded:Connect(function(Unwelcomeone)
	if Unwelcomeone:IsA("Weld") and Unwelcomeone.Name == "RightGrip" then
		Unwelcomeone:Destroy()
	end
end)

Any help is appreciated :wink:

1 Like

For the warning, you just usually wait until the RightGrip weld is finished parenting, or just add weld.Destroying which usually silences that warn

1 Like

How do I wait for the right grip to finish parenting?

script.Parent.DescendantAdded:Connect(function(Unwelcomeone)
	if Unwelcomeone:IsA("Weld") and Unwelcomeone.Name == "RightGrip" then
		task.wait()
		Unwelcomeone:Destroy()
	end
end)
3 Likes

Now usually you’d use while loop like

while weld.Parent == nil do end
--code here

but, its kind of better to do

weld.Destroying:Connect(function()
      print("weld destroying")
end)

so far my most used method to silence that warning

1 Like
local Game = game
local Players = Game:GetService("Players")
local Debris = Game:GetService("Debris")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid", 10)
		if not Humanoid then return end
		local RigType = Humanoid.RigType.Name
		local RightLimb = if RigType == "R6" then Character:FindFirstChild("Right Arm") or Character:WaitForChild("Right Arm", 10) elseif RigType == "R15" then Character:FindFirstChild("RightHand") or Character:WaitForChild("RightHand", 10) else nil
		if not RightLimb then return end
		
		local function OnRightLimbChildAdded(Child)
			if Child.Name ~= "RightGrip" then return end
			Debris:AddItem(Child, 0)
		end
		
		RightLimb.ChildAdded:Connect(OnRightLimbChildAdded)
		for _, Child in ipairs(RightLimb:GetChildren()) do
			OnRightLimbChildAdded(Child)
		end
	end
	
	Players.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)
2 Likes