How do I make when the Player clicks the button again it will tween back down

Hey there. So I want the button to tween down when they click the button again. So right now when a player clicks the button it will tween up and I want it when they click it again it will tween back down. How can I do that? Script :

local isHovering = false

script.Parent.MouseEnter:Connect(function()

	isHovering = true

	wait(0.1)
	script.Parent.Parent.Sound:Play()
	script.Parent.Rotation = script.Parent.Rotation +20
end)

script.Parent.MouseLeave:Connect(function()

	isHovering = false

	wait(0.1)
	script.Parent.Rotation = script.Parent.Rotation -20
end)

script.Parent.MouseButton1Up:Connect(function()
	
	script.Parent.Parent.Sound:Play()
	script.Parent:TweenSize(UDim2.new(0, 85,0, 85), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
	wait(0.1)
	script.Parent:TweenSize(UDim2.new(0, 100,0, 100), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
	script.Parent.Parent.ImageLabel:TweenPosition(UDim2.new(0.237, 0,0.226, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 1, true)

end)

I appreciate your help.

Insert a BoolValue inside the button, and call it Up

script.Parent.MouseButton1Up:Connect(function()
	if script.Parent.Up.Value == false then
	   script.Parent.Parent.Sound:Play()
	   script.Parent:TweenSize(UDim2.new(0, 85,0, 85), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
	   wait(0.1)
	   script.Parent:TweenSize(UDim2.new(0, 100,0, 100), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
	   script.Parent.Parent.ImageLabel:TweenPosition(UDim2.new(0.237, 0,0.226, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 1, true)

       script.Parent.Up.Value = true

    else
       -- Code to tween down
    end
end)
1 Like

Works perfectly as I wanted thanks!

No worries! Good luck developing!