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

Transparency clicker-thing not working?

Asked by
unmiss 337 Moderation Voter
9 years ago

I copied this from a working script I made here, and edited it:

This one is supposed to pop up an information box when you click on another GUI, and it works perfectly:

infobase = script.Parent.Parent.InformationBase
infobase2 = script.Parent.Parent.InformationBase.InformationTitle
infobase3 = infobase2.TextLabel
local droppeddown = false

function infor()
    if droppeddown == false then
        script.Parent.Text = "Close Information"
        infobase.Visible = true
        infobase2.Visible = true
        infobase3.Visible = true
        droppeddown = true
    elseif droppeddown == true then
        script.Parent.Text = "Information"
        infobase.Visible = false
        infobase2.Visible = false
        infobase3.Visible = false
        droppeddown = false
    end
end

script.Parent.MouseButton1Down:connect(infor)

BUT I tried it with THIS which is already visible (=true) but makes it fade in and out, and it doesn't work. I thought there was an easier way to do it, like while variable < 1 do variable = variable +0.1 wait(0.5) end but it does not work and I have to do it the hard way:

donate = script.Parent.Parent.DonateFrame
t = script.Parent.Parent.DonateFrame.BackgroundTransparency
local droppeddown = false

function donate()
    if droppeddown == false then
        script.Parent.Text = "Close Donate"
        t = 1
        t = 0.95
        wait(0.1)
        t = 0.90
        wait(0.1)
        t = 0.85
        wait(0.1)
        t = 0.80
        wait(0.1)
        t = 0.75
        wait(0.1)
        t = 0.70
        wait(0.1)
        t = 0.65
        wait(0.1)
        t = 0.60
        wait(0.1)
        t = 0.55
        wait(0.1)
        t = 0.50
        wait(0.1)
        t = 0.45
        droppeddown = true
    elseif droppeddown == true then
        script.Parent.Text = "Donate"
        t = 0.45
        wait(0.1)
        t = 0.50
        wait(0.1)
        t = 0.55
        wait(0.1)
        t = 0.60
        wait(0.1)
        t = 0.65
        wait(0.1)
        t = 0.70
        wait(0.1)
        t = 0.75
        wait(0.1)
        t = 0.80
        wait(0.1)
        t = 0.85
        wait(0.1)
        t = 0.90
        wait(0.1)
        t = 0.95
        wait(0.1)
        t = 1
        droppeddown = false
    end
end

script.Parent.MouseButton1Down:connect(donate)

Someone please help me... I've had a scorching headache over this and the Extenderframe thing I posted a while ago then deleted (because I gave up on it and nobody was responding) and if you can, help me with the easier way to do it.

Thanks.

1 answer

Log in to vote
0
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

It would be easiest using a loop of any sort. As you can see here below, the code was significantly simplified.. Everything is annotated below ..

t = script.Parent.Parent.DonateFrame
local droppeddown = false

function donate()
    droppeddown = not droppeddown 

    if droppeddown then
        -- if condition is true then
        for i = .45,0.95,.1 do -- start, stop, step
            --set transparency to position at `i`
            t.BackgroundTransparency = i 
            wait(.01) 
        end

    elseif droppeddown == false then
        -- if condition is anything but true (false/nil) then
        for i = 0.95,.45,-.1 do -- start, stop, step
            --set transparency to position at `i`
            t.BackgroundTransparency = i --step
            wait(.01)
        end 
    end
end

script.Parent.MouseButton1Down:connect(donate)

script.Parent.MouseButton1Down:connect(donate)
0
It doesn't work, it instantly goes to fully untransparent then fades away-not helping. The point was to make you click on it, then it fades from 1% transparency to 0.45% transparency.. then if you click Close Donate (which you took out of the script, I believe), it makes it fade from 0.45% to 1% unmiss 337 — 9y
0
This is what you did: http://i.imgur.com/Ovvhhcx.gif unmiss 337 — 9y
0
Try it out again, I had mispelled  `droppeddown` ImageLabel 1541 — 9y
0
Still does not function correctly. unmiss 337 — 9y
View all comments (12 more)
0
it should be.. if the problem is the transparency, you can edit that on lines 9 and 17 to match your needs, taking into consideration that it's laid out (start, stop, step) ImageLabel 1541 — 9y
0
Even if I change it, it still works weirdly, all like this, regardless of how I change it. Strange: http://i.imgur.com/Qgb7LXk.gifv unmiss 337 — 9y
0
is this the only script in the textbutton, or is there another script in there as well? ImageLabel 1541 — 9y
0
Yes, there's a hover script (as you could see in the GIF), and there's a donate script (which is disabled). I tried disabling them both but it still does not function correctly. Is there any other way you can assist me? unmiss 337 — 9y
0
i'd have to get on a laptop and re-produce it myself to see what's wrong because I can't test it right now so give me a few ImageLabel 1541 — 9y
0
Okay then. If you can, do you know if there's a way to move or resize a GUI to a certain point, such as 'while variable < 7 do variable = variable.Size.X.Offset +1', or something like that? unmiss 337 — 9y
0
alright fixed, tested myself and is now working. ImageLabel 1541 — 9y
0
okay.... unmiss 337 — 9y
0
well..? Did you test it? Is it not working? If there's anything else you have in this very script except what i posted, share it. ImageLabel 1541 — 9y
0
Nothing else. Had to use the tweenposition method. unmiss 337 — 9y
0
you mean my code didn't work? ImageLabel 1541 — 9y
Ad

Answer this question