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

How can I start this function when a GUI is visible?

Asked by 8 years ago

I have this simple part of a script

wait(5)
if FRAME.Visible == true then 
 repeat 
    wait(3)check_Have() print("checking...")
    until 
    FRAME.Visible == false  
end

Which does what I want it to, it runs the check_Have() function if the frame is visible after the 5 second wait, but I want it to be able to recognize when the FRAME goes from not visible to visible. Basically this works for when the frame is already visible but not for when it becomes visible after the 5 seconds. How would I notify the script that the frame has become visible?

0
Do you mean only if it's changed from not visible to visible? GoldenPhysics 474 — 8y
0
Couldn't you just use FRAME.Changed:print("The frame has changed")? That's just an idea, as I don't quite understand your question. RedCombee 585 — 8y
0
sorry I should have been more clear. When I said "notify the script" I mean't write in Lua what I want the script to do. Basically my question is how do I tell the script that when the frame BECOMES visible I want it to do the check_Have() function Gwolflover 80 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
FRAME.Changed:connect(function(prop)
    if prop == 'Visible' and frame.Visible == true then
        repeat
            wait(3) 
            check_Have()
            print('Checking...')
        until FRAME.Visible == false
    end
end)

I assume this is what you meant. The Changed event fires when a property of the frame changes and gives you a string containing the name of the property, in this case prop. It then checks that the visibility changed to true and if it did it then does your repeat loop.

0
Perfect! thank you so much! Gwolflover 80 — 8y
Ad

Answer this question