Tweened part won't reverse

Hello,

I am making a factory game thing and there is a presser that brings down a metal plate at high speeds to the floor. Here is the script:

local effect = script.Parent.Spark
local pos = script.Parent.Crusher.Position
local sparks = effect:GetChildren()
local tweenService = game:GetService("TweenService")
local onthewayUpInfo = TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false,0)
local onthewayDownInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, 0, false,0)

local function enableEffects()
	for i, v in pairs(sparks) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = true
		else

		end
	end
	wait(0.4)
	for i, v in pairs(sparks) do
		if v:IsA("ParticleEmitter") then
			v.Enabled = false
		else
		end
	end
end

while wait() do
	local tweenDown = tweenService:Create(script.Parent.Crusher, onthewayDownInfo, {Position = script.Parent.Crusher.Position - Vector3.new(0,6,0); Size = script.Parent.Crusher.Size + Vector3.new(0,12,0)})
	local tweenUp = tweenService:Create(script.Parent.Crusher, onthewayUpInfo, {Position = pos; Size = script.Parent.Crusher.Size + Vector3.new(0,-12,0)})
	tweenDown:Play()
	repeat wait() until tweenDown.PlaybackState == Enum.PlaybackState.Completed
	enableEffects()
	tweenUp:Play()
end

For some reason, it “crusher” part just keeps extending, pause, extending, pause, instead of retreating back to its original position like it’s supposed to. Any help would be appreciated! I am also getting no errors in the output.

1 Like

You forgot to wait for the tweenUp animation to finish before restarting the while loop. You could try running repeat wait() until ... or tweenUp.Completed:Wait() right after that tween, that would make the loop wait for the crusher to move back up.

1 Like

You arent even telling the Tween to Reverse, one of the Properties with TweenInfo allows you to Reverse the Tween, but its set to false.

1 Like