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

How do I make sure that my text does not stay the same after I hover out of a TextButton?

Asked by
Narunzo 172
6 years ago

So I was making buttons for my menu and I noticed if a player hovers over the button and leaves it fast enough or presses esc it still shows the full text this is the script...

function Enter()
    script.Parent.Parent.Parent.CharacterButton.HoverFrame.Visible=false
    script.Parent.Parent.Parent.FamiliarButton.HoverFrame.Visible=false
    script.Parent.Parent.Parent.BagButton.HoverFrame.Visible=false
    script.Parent.Parent:TweenSize(UDim2.new(0,173,0,75),"Out","Quad",0.25,true)
    script.Parent.Parent:TweenPosition(UDim2.new(0,-98,0.5,-37),"Out","Quad",0.25,true)
    wait()
    script.Parent.Parent.Text="Menu"
end
function Leave()
    wait()
    script.Parent.Parent.Text="E"
    wait()
    script.Parent.Parent:TweenSize(UDim2.new(0,75,0,75),"Out","Quad",0.25,true)
    script.Parent.Parent:TweenPosition(UDim2.new(0,0,0.5,-37),"Out","Quad",0.25,true)
    wait()
    script.Parent.Parent.Parent.CharacterButton.HoverFrame.Visible=true
    script.Parent.Parent.Parent.FamiliarButton.HoverFrame.Visible=true
    script.Parent.Parent.Parent.BagButton.HoverFrame.Visible=true
    wait()
    if not script.Parent.Parent.Text=="E"then
    script.Parent.Parent.Text="E"
end
end
script.Parent.MouseEnter:connect(Enter)
script.Parent.MouseLeave:connect(Leave)

I have the script in a FrameGui inside the button so that when a player clicks on the button it does not count it as them leaving the gui.

1 answer

Log in to vote
0
Answered by
tantec 305 Moderation Voter
6 years ago

You should consider removing the unnecessary wait()s

function Enter()
    script.Parent.Parent.Parent.CharacterButton.HoverFrame.Visible=false
    script.Parent.Parent.Parent.FamiliarButton.HoverFrame.Visible=false
    script.Parent.Parent.Parent.BagButton.HoverFrame.Visible=false
    script.Parent.Parent:TweenSize(UDim2.new(0,173,0,75),"Out","Quad",0.25,true)
    script.Parent.Parent:TweenPosition(UDim2.new(0,-98,0.5,-37),"Out","Quad",0.25,true)
    script.Parent.Parent.Text="Menu"
end
function Leave()
    script.Parent.Parent.Text="E"
    script.Parent.Parent:TweenSize(UDim2.new(0,75,0,75),"Out","Quad",0.25,true)
    script.Parent.Parent:TweenPosition(UDim2.new(0,0,0.5,-37),"Out","Quad",0.25,true)
    script.Parent.Parent.Parent.CharacterButton.HoverFrame.Visible=true
    script.Parent.Parent.Parent.FamiliarButton.HoverFrame.Visible=true
    script.Parent.Parent.Parent.BagButton.HoverFrame.Visible=true
    if not script.Parent.Parent.Text=="E"then
    script.Parent.Parent.Text="E"
end
end
script.Parent.MouseEnter:connect(Enter)
script.Parent.MouseLeave:connect(Leave)
0
What do you mean? How will that help? Narunzo 172 — 6y
0
Because you are making the script and because of this, let's say the Enter function is running, and with your waits it's taking much longer then usual and while the Enter function is running the Leave function is suddenly run at the same time it won't really work will it? tantec 305 — 6y
0
Are you saying that I should make the Enter fast enough to end before the player leaves so that both the Enter and Leave can work without trying to run over the other? Narunzo 172 — 6y
0
Yes. tantec 305 — 6y
Ad

Answer this question