MouseEnter Button Fade?


#1

How would I set the transparency of a textbutton from 1-0 smoothly upon my mouse entering the button (Preferably w/ a for loop as I’d like to learn more about them. :))?


#2

You should try using tweens instead, they’re pretty useful in making things appear smooth with the use of easing styles :smiley:


#3

I would, but I’m trying to make the game eerie kinda and it doesn’t really fit what I’m attempting. :slight_smile:


#4

TweenService is the way to go! :slightly_smiling_face:

You’ll want to use the event .MouseEnter as you said and tween the transparency using Tween.Create

local TweenService = game:GetService("TweenService")
local Item = Button
local info =  TweenInfo.new(
	0.75,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut
	)
	local goals = {
			ImageTransparency = 1
	}
local Animate = TweenService:Create(Item,info,goals)
Animate:Play()

You can change the easing style to try to cater what you want to try out.


#5

Could you explain in more detail of what you’re trying to attempt?
It would help us to help you more if we understood.

(sorry if that sounded a bit off…)


#6

You may need to make use of RenderStepped event on RunService.


#7

Basically, instead of using one while loop with 10 lines, and 10 wait()'s to change the transparency of the TextButton, I want to do it w/ a for loop as I feel as it’s much more efficient.


#8

Hmmm, I don’t think loops are the best way to go, since you’re also using MouseEnter to make it happen which can appear VERY glitchy. Instead, you can use a plugin that changes tweens :smiley:

https://www.roblox.com/library/2705651566/TweenSequence-Editor

^^^ Will be very handy in trying to create your own “custom” tweens :stuck_out_tongue:


#9

I’ll attempt this one, thanks both of you! (:


#10

Your welcome! Glad to help :smiley:


#11

Or… you could do

for i = 1,0,-.1 do
TextButton.BackgroundTransparency = i
TextButton.TextTransparency = i
wait()
end

#12

Yes you could do that but since its MouseEnter, hovering on and off it quickly can make it looks very glitchy and odd.


#13

Could make a boolean that checks if the transparency is 0/1 so the code wouldn’t run again so fast.


#14

Thats true but, that could cause a noticeable delay in the fade wouldn’t it?


#15

I’ll actually be using this one, works well! Thank you Hoan and Jordy also. :slight_smile:


#16

Your welcome! Glad to help you :stuck_out_tongue:
Good luck on developing your game btw!


#17

Thank you! Good luck on your project(s) aswell!


#18

You should use TweenService as uJordy posted. The “tween” listed as the solution can’t be overwritten and if you try, it’d appear “glitchy”. Using a Boolean to debounce it wouldn’t be appropriate either, because then it wouldn’t give you the kind of effect that you desire.

Tweens made from TweenService can be overwritten (and automatically too) if you play a tween overtop it. You get the effect you want and you don’t get the overhead of having to account for any extraneous or unnecessary behaviour.

Tweens for aesthetic over iteration are definitely the way to go.