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

why won't my function connect and text appear?

Asked by 7 years ago

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

function ChangeOfMoneyGui(clicker)
    db = 0
    print("function connected")
    if db == 0 then
        db = 1
        print("debounce active")
        local plrg = clicker:FindFirstChild("PlayerGui")
        local mc = plrg.ChangeOfMoney.MoneyChangeFrame.MoneyChange
        local tt = mc.TextTransparency
        local st = mc.TextStrokeTransparency
        visible = false
        if visible == false then
            print("visible = true")
            visible = true
            appear(tt)
            appear(st)
            wait(2)
            disappear(tt)
            disappear(st)
            visible = false
        end
    end
end

game.Workspace.ClickyClick.ClickDetector.MouseClick:connect(ChangeOfMoneyGui)


function appear(transparency)
    print("appear function called")
    for i = 1, 0, .05 do
    transparency = i
    end
end 


function disappear(transparency)
    print("disappear function called")
    for i = 0, 1, .05 do
    transparency = i
    end
end
0
messed up on title, function *did* connect except the text just won't appear creeperhunter76 554 — 7y

2 answers

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

The text doesn't appear because you are never updating its transparency. In the code

function appear(transparency)
    print("appear function called")
    for i = 1, 0, .05 do
    transparency = i
    end
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

function appear(label)
    print("appear function called")
    for i = 1, 0, .05 do
        label.TextTransparency = i
        label.TextStrokeTransparency = i
        wait()
    end
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.

0
thanks, worked! creeperhunter76 554 — 7y
0
No problem MightyBaconOverlord 253 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You get the Value of the Transparency and not set it to the new value and you did this loop:

for i = 1, 0, .05 do

this will not decrease i so it gets visible again you need to do the loop like this:

for i = 1, 0, -.05 do

try this :

function appear(object)
    print("appearing")
    for i = 1, 0, -.05 do
        object.TextTransparency = i
        object.Transparency = i
    end
end

function dissappear(object)
    print("dissappearing")
    for i = 0, 1, 0.5 do
        object.TextTransparency = i
        object.Transparency = i
    end
end

function ChangeOfMoneyGui(clicker)
    db = 0
    print("connected")
    if db == 0 then
        db = 1
        print("debounce")
        local plrgs = clicker:FindFirstChild("PlayerGui")
        local mc  = plrgs.ChangeOfMoney.MoneyChangeFrame.MoneyChange
        visible = false
        if visible == false then
            print("visible now")
            visible = true
            appear(mc)
            wait(2)
            dissappear(mc)
            visible = false

        end
    end
end

game.Workspace.ClickyClick.ClickDetector.MouseClick:connect(ChangeOfMoneyGui)

Answer this question