Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

	 

2 comments

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

0

use the print() method whenever possible, its extremely helpful when debugging.

1 answer

✓ Accepted answer

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

1 comment

0

"put you an else statement" ;D

This discussion is preserved as it was. New answers, comments, and votes are closed.