I've created a script that, upon click of "ClickyClick", makes a TextLabel gradually increase its transparency and all of my prints work except the text doesn't appear
01 | function ChangeOfMoneyGui(clicker) |
02 | db = 0 |
03 | print ( "function connected" ) |
04 | if db = = 0 then |
05 | db = 1 |
06 | print ( "debounce active" ) |
07 | local plrg = clicker:FindFirstChild( "PlayerGui" ) |
08 | local mc = plrg.ChangeOfMoney.MoneyChangeFrame.MoneyChange |
09 | local tt = mc.TextTransparency |
10 | local st = mc.TextStrokeTransparency |
11 | visible = false |
12 | if visible = = false then |
13 | print ( "visible = true" ) |
14 | visible = true |
15 | appear(tt) |
The text doesn't appear because you are never updating its transparency. In the code
1 | function appear(transparency) |
2 | print ( "appear function called" ) |
3 | for i = 1 , 0 , . 05 do |
4 | transparency = i |
5 | end |
6 | end |
you are only updating the variable transparency
and not the actual transparency of the label's text. To make this work, consider using this function
1 | function appear(label) |
2 | print ( "appear function called" ) |
3 | for i = 1 , 0 , . 05 do |
4 | label.TextTransparency = i |
5 | label.TextStrokeTransparency = i |
6 | wait() |
7 | end |
8 | end |
and calling it by passing the label mc
as an argument. Do similarly for disappear
. Keep in mind you will want to call wait
upon each loop iteration to prevent the text from appearing instantly.
You get the Value of the Transparency and not set it to the new value and you did this loop:
1 | for i = 1 , 0 , . 05 do |
this will not decrease i so it gets visible again you need to do the loop like this:
1 | for i = 1 , 0 , -. 05 do |
try this :
01 | function appear(object) |
02 | print ( "appearing" ) |
03 | for i = 1 , 0 , -. 05 do |
04 | object.TextTransparency = i |
05 | object.Transparency = i |
06 | end |
07 | end |
08 |
09 | function dissappear(object) |
10 | print ( "dissappearing" ) |
11 | for i = 0 , 1 , 0.5 do |
12 | object.TextTransparency = i |
13 | object.Transparency = i |
14 | end |
15 | end |