Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't the animation work? GUI Tweening.

I am tweening gui but I can't fix this, I want it two execute both functions, but it doesn't work.

local ImageButton = script.Parent.Parent:WaitForChild('NavGUI').ImageButton
local button = script.Parent
local toggled = false

local function onButtonActivated()
	if toggled == false then
		button.Image = "rbxgameasset://Images/Dropdown-active"
		toggled = true
	else		
		button.Image = "rbxgameasset://Images/Dropdown-null"
		toggled = false
		
	end
end
 
local function Animation()
	if toggled == false then
		ImageButton:TweenPosition(UDim2.new(0.5, -250, 0.5, -200), 'Out', 'Bounce', 1)
	else		
		ImageButton:TweenPosition(UDim2.new(0.5, -250, 1.7, -200), 'Out', 'Bounce', 1)
	end
end
--
--
button.Activated:Connect(onButtonActivated)
button.Activated:Connect(Animation)

1 answer

✓ Accepted answer

Would calling the Animation() function in onButtonActivated work?

Like this:

local ImageButton = script.Parent.Parent:WaitForChild('NavGUI').ImageButton
local button = script.Parent
local toggled = false



local function Animation()
    if toggled == false then
        ImageButton:TweenPosition(UDim2.new(0.5, -250, 0.5, -200), 'Out', 'Bounce', 1)
    else        
        ImageButton:TweenPosition(UDim2.new(0.5, -250, 1.7, -200), 'Out', 'Bounce', 1)
    end
end


local function onButtonActivated()

    if toggled == false then
        button.Image = "rbxgameasset://Images/Dropdown-active"
        toggled = true
    else        
        button.Image = "rbxgameasset://Images/Dropdown-null"
        toggled = false
    end
Animation()
end
--
--
button.Activated:Connect(onButtonActivated)

Or doing something like this?

button.Activated:Connect(function()
	Animation()
	onButtonActivated()
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.