Tweens in a tool result in the part getting offset if the player is moving. Solutions?

In summary,
My code ( attached below ) is a function which can be called upon to play an animation where a bolt gets racked backwards, then forwards again using TweenService. I am purposefully staying away from Motor6D animations, and any Roblox animations in general with the tool.

If the player moves, like walking, turning, or even the idle animation playing, and the tween is also playing, the part will be offset and not appear where it should. Are there any solutions/work arounds to this?

Code:

local function kickBack()	
	local goal = {}
	local goalCframe = bolt.CFrame - bolt.CFrame.RightVector * 0.3

	goal.Position =  goalCframe.Position

	local tweenInfo = TweenInfo.new(

		-- lol copypasted from the documentation so there are comments here
		fireRate.Value/2, -- Time
		Enum.EasingStyle.Quint, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		true, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)

	local tween = TweenService:Create(bolt, tweenInfo, goal)

	tween:Play()
end
2 Likes