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

Werid UI Glitch?

Asked by 9 years ago

In this script I have a GUI grow when its hovered over and when its not hovered it shrinks. I think there is glitch is that sometimes the the mouse will glitch the GUI so it doesn't grow or doesn't go shrink back to its original state. Is there a fix?

local AboutParent = script.Parent





--[[Open Script]]--

AboutParent.MouseButton1Click:connect(function()


    AboutParent.Parent.AboutFrame.Visible = true
    AboutParent.Parent.AboutFrame:TweenSize(UDim2.new(0.6, 0, 0.6, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1)
        for i=1, 0,-.05 do      
         wait(.01)
         AboutParent.Parent.AboutFrame.AboutTitleBox.TextTransparency = i 
        end
    AboutParent:TweenPosition(UDim2.new(.04,0,.46,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5)
end)
--[[Hover Script]]--

AboutParent.MouseEnter:connect(function(x, y)   
        AboutParent:TweenSize(UDim2.new(.2,0,.16,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5)
end)


AboutParent.MouseLeave:connect(function(x, y)
        AboutParent:TweenSize(UDim2.new(.18,0,.14,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5)
end)

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

I'm going to assume that your mouse is leaving the gui before the initial Tweening(from the MouseEnter event) is done with. The tweening requests aren't cached or anything.. so it just won't tween it.

To fix? The last argument of the TweenSize function is 'ovveride'. This makes it so a tween can be interrupted by another tween. Set this to true(:

local AboutParent = script.Parent

--[[Open Script]]--

AboutParent.MouseButton1Click:connect(function()
    AboutParent.Parent.AboutFrame.Visible = true
    AboutParent.Parent.AboutFrame:TweenSize(UDim2.new(0.6, 0, 0.6, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1)
    for i=1, 0,-.05 do      
        wait(.01)
        AboutParent.Parent.AboutFrame.AboutTitleBox.TextTransparency = i 
        end
    AboutParent:TweenPosition(UDim2.new(.04,0,.46,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5)
end)

--[[Hover Script]]--

--Parameters are redundant.. since you're not using them.
AboutParent.MouseEnter:connect(function()
    --Last argument is 'true'
    AboutParent:TweenSize(UDim2.new(.2,0,.16,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5,true)
end)

AboutParent.MouseLeave:connect(function()
    AboutParent:TweenSize(UDim2.new(.18,0,.14,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,.5,true)
end)
Ad

Answer this question