Weird Weld Constraint Behavior

Basically I welded the characters using weldconstraint which I ended up destroying at a certain part in the script. After I tweened the npcs position from point a to point b then npc would start to behave abnormally. Honestly I have no clue whats going on with the npc so im on here asking anyone if theres something I did or if this is a roblox bug.

Heres my script:

    local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(
	.75, -- Length
	Enum.EasingStyle.Sine, -- Easing Style
	Enum.EasingDirection.Out, -- Easing Direction
	0, -- Times repeated
	false, -- Reverse
	0 -- Delay
)

script.Parent.OnServerEvent:Connect(function(Player)
	
	local Char = Player.Character
	local HRP = Char.HumanoidRootPart
	
	
	
	
	local R = Ray.new(HRP.Position, HRP.CFrame.LookVector * 15)

	
	local hitPart, hitPosition = workspace:FindPartOnRay(R,Char)
	
	
	if hitPart and hitPart.Parent:FindFirstChild('Humanoid') then
	
		
		local Person = hitPart.Parent
		local PersonHum Person:FindFirstChild('Humanoid')
		
		Person.HumanoidRootPart.CFrame = HRP.CFrame * CFrame.new(0,0,-2) * CFrame.fromEulerAnglesXYZ(math.rad(0),math.rad(180),math.rad(0))
		
		
		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = HRP
		Weld.Part1 = Char.Torso
		Weld.Part0 = Person.HumanoidRootPart
		
		
		
		spawn(function()
			local CharAnim = Char.Humanoid:LoadAnimation(script.Spinning)
			CharAnim:Play()
			
			spawn(function()
				CharAnim.Stopped:wait()
				print("Animation has stopped")
				
				
				local InsPart = Instance.new("Part")
				InsPart.Anchored = true
				InsPart.CFrame = HRP.CFrame * CFrame.new(0,55,-55)
				InsPart.Parent = workspace
				InsPart.CanCollide = false
				InsPart.Transparency = 1
				InsPart.Name = 'ToTween'
				
				local Goals =
					{
					Position = InsPart.Position
				}
				
				local Goals2 =
					{
					Position = InsPart.Position + Vector3.new(0,3,0)
				}
				
				local FlingTween = TweenService:Create(Person.HumanoidRootPart,Info,Goals)
				local CharTween = TweenService:Create(HRP,Info,Goals2)
				Weld:Destroy()
				FlingTween:Play()
				
				
				spawn(function()
					wait(.25)
					local CharJumpAnim = Char.Humanoid:LoadAnimation(script.Jump)
					CharJumpAnim:Play()
					
					CharTween:Play()
					wait(.5)
					local Weld2 = Instance.new("WeldConstraint",InsPart)
					Weld2.Part1 = InsPart
					Weld2.Part0 = HRP
					Weld2.Name = 'CharacterWeld'
					CharJumpAnim:Stop()
					
					local CharPunchAnim = Char.Humanoid:LoadAnimation(script.Punch)
					CharPunchAnim:Play()
					
					
					
					local Smash = script.Smash:Clone()
					Smash:SetPrimaryPartCFrame(HRP.CFrame * CFrame.new(0,50,0))
					Smash.Parent = workspace
					
					wait(.05)
					Smash.Scripts.Start.Disabled = false
					
					
					FlingTween:Cancel()
					InsPart:Destroy()
					
					
				end)
				
				
				FlingTween.Completed:Wait()
				Person.HumanoidRootPart.Anchored = true
				print('gee')
				Person.HumanoidRootPart.Anchored = false
			end)
			
			local PersonAnim = Person.Humanoid:LoadAnimation(script.GrabbedAnim)
			PersonAnim:Play()
			
		end)
	
		
	else
		print("Did not hit part")
	end
	
	
end)

Ok, What was printed out when you ran it?

Nothing, It showed no errors in the output.

image

These were to debug and see if I could find the problem but everything was still functioning right.

I am not sure if this is the problem here, but this is definitely something you should not do in a Model with welded parts: Model.HumanoidRootPart.CFrame = ...

The reason being that if you set the position/cframe of a part that is welded to other parts using the Weld or Snap objects, the Weld/Snap destroy themselves and when they do, it changes the hierarchical structure of the whole model in the context of animations as well, so the animations will play as if those limbs weren’t even here.

In any case, you should use Model:SetPrimaryPartCFrame(cframe) instead since the HumanoidRootPart is the RootPart of the Model anyway.