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

Why my TweenAnimation works only for few clicks and after is it going to broke?

Asked by 5 years ago
Edited 5 years ago

This question has been solved by the original poster.

Sorry for bad english

I have write this animation:

When you open the Redeem Code (Frame)

local TweenService = game:GetService("TweenService")
local Animation = TweenInfo.new(0.5,Enum.EasingStyle.Back)
local RedeemTarget = {Position = UDim2.new(0.53, 0,0.476, 0)}
local AnimationBack = {Position = UDim2.new(0.5, 0,1.5, 0)}

local debounce = false
local function OnOpenButton()
    if not debounce then
        debounce = true
        Frame.Visible = true
        local Image = TweenService:Create(Frame,Animation,RedeemTarget)
        Image:Play()
        if Pets.Visible == true then
            local Image1 = TweenService:Create(Pets,Animation,AnimationBack)
            Image1:Play()
            Image1.Completed:Wait()
            Pets.Visible = false
            Pets.Position = UDim2.new(0.5, 0,-1.5, 0)
            debounce = false
        elseif Shops.Visible == true then
            local Images = TweenService:Create(Shops,Animation,AnimationBack)
            Images:Play()
            Images.Completed:Wait()
            Shops.Visible = false
            Shops.Position = UDim2.new(0.499, 0,-1.5, 0)
            debounce = false
        end
    end
end
OpenButton.Activated:Connect(OnOpenButton)

When you open the Shop

local TweenService = game:GetService("TweenService")
local Animation = TweenInfo.new(0.5,Enum.EasingStyle.Back)
local ShopTarget = {Position = UDim2.new(0.499, 0,0.476, 0)}
local AnimationBack = {Position = UDim2.new(0.5, 0,1.5, 0)}

local debounce = false
local function OnOpenButton()
    if not debounce then
        debounce = true
        ShopFrame.Visible = true
        local ImageTween1 = TweenService:Create(ShopFrame,Animation,ShopTarget)
        ImageTween1:Play()
        OpenMoneyButton.Image = COINS_NORMAL
        CoinFrame.Visible = false
        OpenDiamondButton.Image = DIAMOND_NORMAL
        DiamondFrame.Visible = false
        OpenGamepassButton.Image = GAMEPASS_CLICK
        GamepassFrame.Visible = true
        Bar.Visible = true
        if CodeRedeem.Visible == true then
            local ImageTween = TweenService:Create(CodeRedeem,Animation,AnimationBack)
            ImageTween:Play()
            ImageTween.Completed:Wait()
            CodeRedeem.Visible = false
            CodeRedeem.Position = UDim2.new(0.53, 0,-1.5, 0)
            debounce = false
        elseif Pets.Visible == true then
            local Image = TweenService:Create(Pets,Animation,AnimationBack)
            Image:Play()
            Image.Completed:Wait()
            Pets.Visible = false
            Pets.Position = UDim2.new(0.5, 0,-1.5, 0)
            debounce = false
        end
    end
end
ActiveShopButton.Activated:Connect(OnOpenButton)

I have try before without the Debounce, but the animation goes to Break. After 5-6 Click, nothing appear. Animations remain blocked and i can't see Frames.

With Debounce, they'll go still blocked after 2 Click.

WHo can help me?

1 answer

Log in to vote
0
Answered by 5 years ago

Fixed. i have only change the speed of my animation.

Ad

Answer this question