Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't the animation work? GUI Tweening.

Asked by
iHavoc101 127
4 years ago

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

Log in to vote
0
Answered by
Thetacah 712 Moderation Voter
4 years ago
Edited 4 years ago

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)

Ad

Answer this question