Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

4 comments

0

What do you mean? How will that help?

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?

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?

0

Yes.

This discussion is preserved as it was. New answers, comments, and votes are closed.