Essentially, I have a part which is welded the the torso of a humanoid. The torso moves via tweens. I’m trying to transfer the part between the torso and another stationary part in a smooth tween.
The way my code so far works is that it:
- Anchors the part
- Destroys the weld
- Runs the tween
- Un-anchors the part
- Welds the part to our stationary part
There are a few bizarre problems I’ve run into, primarily when the tween starts, the part appears at the starting position of the torso, which has moved.
Maybe I just don’t understand welds well enough, I’ve tried to get around these issues multiple ways such as applying the parts CFrame to a CFrame value saved before the weld is broken. Perhaps there’s a different way to get the position of a part in a weld? I’ve tried CFrame and Position for the tween, both give me the same output.
Here’s the code snippet, “metal” is the part:
--Make tween
local ti = TweenInfo.new(.3, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut)
local propertyToTween = {CFrame = script.Parent.MagnaGun.CollectionPoint.Point1.CFrame}
local tween = ts:Create(metal, ti, propertyToTween)
local pos = metal.CFrame --Save part CFrame
metal.Anchored = true
metal:FindFirstChildOfClass("Weld"):Destroy() --Destroy weld
metal.CFrame = pos --Set position to archived one
tween:Play()
tween.Completed:Wait() --wait for tween to complete
metal.Anchored = false
--Make and apply new weld, weld to stationary part
local weld = Instance.new("Weld")
weld.Part0 = script.Parent.MagnaGun.CollectionPoint
weld.Part1 = metal
metal.Parent = script.Parent
weld.Parent = metal
Many thanks.