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

My gui breaks if you stop hovering over it too quickly?

Asked by 6 years ago

I'm not sure why this is but if you hover over my gui, it becomes larger. If you stop hovering over it before the "TweenSize" animation plays, it doesn't size down and stays larger.

If you could help that would be awesome!

Player = game.Players.LocalPlayer
Menu = script.Parent
Play = Menu.Play
About = Menu.About

function MouseEnterPlayButton()
    Play.FontSize = "Size48"
    Play:TweenSize(UDim2.new(0.35, 0, 0.1, 0), "Out", "Sine", 1)
end

function MouseEnterAboutButton()
    About.FontSize = "Size48"
    About:TweenSize(UDim2.new(0.35, 0, 0.1, 0), "Out", "Sine", 1)
end

function MouseLeftPlayButton()
    Play.FontSize = "Size36"
    Play:TweenSize(UDim2.new(0.25, 0, 0.1, 0), "Out", "Sine", 1)
end

function MouseLeftAboutButton()
    About.FontSize = "Size36"
    About:TweenSize(UDim2.new(0.25, 0, 0.1, 0), "Out", "Sine", 1)
end

Play.MouseEnter:connect(MouseEnterPlayButton)
About.MouseEnter:connect(MouseEnterAboutButton)
Play.MouseLeave:connect(MouseLeftPlayButton)
About.MouseLeave:connect(MouseLeftAboutButton)

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You should tween in after you tween out, like this.

Player = game.Players.LocalPlayer
Menu = script.Parent
Play = Menu.Play
About = Menu.About
PlayButton = false

function MouseEnterPlayButton()
    if not PlayButton then
    Playbutton = true
    Play.FontSize = "Size48"
    Play:TweenSize(UDim2.new(0.35, 0, 0.1, 0), "Out", "Sine", 1)
    wait(1)
    PlayButton = false
    end
end

function MouseEnterAboutButton() --Copy what I did from the other functions here.
    About.FontSize = "Size48"
    About:TweenSize(UDim2.new(0.35, 0, 0.1, 0), "Out", "Sine", 1)
end

function MouseLeftPlayButton()
    repeat wait() until not PlayButton
    PlayButton = true
    Play.FontSize = "Size36"
    Play:TweenSize(UDim2.new(0.25, 0, 0.1, 0), "Out", "Sine", 1)
    wait(1)
    PlayButton = false
end

function MouseLeftAboutButton()
    About.FontSize = "Size36"
    About:TweenSize(UDim2.new(0.25, 0, 0.1, 0), "Out", "Sine", 1)
end

Play.MouseEnter:connect(MouseEnterPlayButton)
About.MouseEnter:connect(MouseEnterAboutButton)
Play.MouseLeave:connect(MouseLeftPlayButton)
About.MouseLeave:connect(MouseLeftAboutButton)

It waits for the tweening out to get finished to tween in. Hope this helps!

Ad

Answer this question