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

MouseButton1Click only triggers the function once, how do I make it so it works every time?

Asked by 7 years ago

I have a script that makes it so when you click a text button, it activates and deactivates the parent of the text button (Which is a frame) However, when it's pressed, it doesn't work again. How can I fix it?

Here is my code:

Book = script.Parent


Frame = Book.Parent

function onClick()



     if Frame.BackgroundTransparency == 1 then
        Frame.BackgroundTransparency = 0
    end

    if Frame.BackgroundTransparency == 0 then
        Frame.BackgroundTransparency = 1
    end

end



Book.MouseButton1Click:connect(onClick)


0
put a "print("Inside Function") or something of the sort to confirm the function is being run each time. Then it would have something to do with the code inside the function dragonkeeper467 453 — 7y
0
use the print() method whenever possible, its extremely helpful when debugging. dragonkeeper467 453 — 7y

1 answer

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

Put you an else that way if its not anything else would be that

if Frame.BackgroundTransparency == 1 then
    Frame.BackgroundTransparency = 0 
else
       Frame.BackgroundTransparency = 1
end
0
"put you an else statement" ;D dragonkeeper467 453 — 7y
Ad

Answer this question