How can I Keep a weld stay welded when I move the second weld part?

I Was working on a limb mechanic with a tool and i’ve encountered a problem that when I run a weld it will just destroy itself.
I’ve tried using other inbuilt roblox mechanics like attach but it didn’t do anything like the weld did.
Heres the script I wrote:

local UIS = game:GetService("UserInputService")
local char = script.Parent.Parent
local h = char.Humanoid
local anim 
UIS.InputBegan:Connect(function(key)
	local k = key.KeyCode
	if k == Enum.KeyCode.E then
		local weld = Instance.new("Weld")
		anim = h:LoadAnimation(script.Animation)
		anim:Play()
		weld.Part0 = script.Parent.Handle
		weld.Part1 = script.Parent.Handle.Part
	end
end)

Shouldn’t you assign the weld.Part0 and weld.Part1 before you run the animation?

Also, are you trying to move the Tool Parts with the Animation, or just trying to keep the Handle and Part attached together?

I Am trying to attach the handle and the part together

Why not just use a WeldConstraint instead of scripting it? Select the Handle first, click the Constraints tab in the Studio Model tab, click on the Weld constraint in the drop-down, then click on the Part. They will be welded as the two Parts sit.
The nice thing about the Constraint weld is if you decide you want to move the Part in relation to the Handle while building, the Weld won’t disappear like a scripted weld.

I Didn’t quite get where are can I get the WeldConstraint in the Studio Model tab?
Did you mean in the create option?

Can you explain better what’s the issue? What happens when you run the code?

When I run the code, The weld turns on for a split seconds and then turns itself off

Did you try the Create tab?

Yes, it’s that one. If you’ve been a Programmer mostly you should explore the Studio tabs and tools to see what they do. Might save you some time in the future too.

You forgot to parent the weld

local weld = Instance.new("Weld", script.Parent.Handle)
anim = h:LoadAnimation(script.Animation)
anim:Play()
weld.Part0 = script.Parent.Handle
weld.Part1 = script.Parent.Handle.Part

Yep that was the part that I missed…