I've made a script that animated my buttons, but for some reason, the button wont go back up. I wonder whats the problem

Here's the script:

local top_button = script.Parent.Parent.Parent.Top
local bottom_button = script.Parent.Parent.Parent.Bottom
local clicky = script.Parent
local sfx = script.Click
local frame = script.Parent.Parent.Parent.Parent.Frame
local clicked = false

clicky.MouseButton1Click:Connect(function()
	if clicked == false then
		clicked = true
		sfx:Play()
		top_button:TweenPosition(UDim2.new(0,0,0.001,0),"In","Linear",.1)
		wait()
		top_button:TweenPosition(UDim2.new(0,0,-.1,0),"In","Linear",.1)
		frame.Visible = true
	else
		clicked = false
		sfx:Play()
		top_button:TweenPosition(UDim2.new(0,0,0.001,0),"In","Linear",.1)
		wait()
		top_button:TweenPosition(UDim2.new(0,0,-.1,0),"In","Linear",.1)
		frame.Visible = false
	end
end)

If you want to see the button, here: https://cdn.discordapp.com/attachments/354072857971654658/602666117105975296/robloxapp-20190721-1758289.wmv

2 comments

0

Have you tried using lerp instead of tween?

0

Tweening is better