Tween position problem

I am having trouble with making an idle kind of look on this part:
image

each time it tweens it seems to go down 5 studs before starting each tween and i can litterally do nothing to fix it, here is the script.


local part = script.Parent 
local TweenService = game:GetService("TweenService")


local resetPosition = Vector3.new(8.248, 5.752, -167.323)


local tweenInfo = TweenInfo.new(
	1, 
	Enum.EasingStyle.Cubic, 
	Enum.EasingDirection.InOut,
	-1,
	true
)


local goalUp = {Position = resetPosition + Vector3.new(0, 5, 0)}

local function startTween()
	local tween = TweenService:Create(part, tweenInfo, goalUp)
	tween:Play()
	part.Position = resetPosition
end


startTween()

1 Like

Hello, your issue here is that you’re trying to reset the position of the part directly after playing the tween, which will just get overridden by the tween. Tween:Play() does not pause the thread (basically doesn’t pause the script) when called, meaning that the rest of the code will run even if the tween didn’t finish yet. If you want to wait until a tween is finished before resetting the position, add this to your code:

tween:Play()
tween.Completed:Wait()
part.Position = resetPosition

Hope this helps!