01 | wait(. 03 ) |
02 | local enabled = true |
03 | Player = game.Players.LocalPlayer |
04 | xbc = script.Parent |
05 | control = Player.Backpack.Controls |
06 |
07 | xbc.MouseButton 1 Down:connect( function (Play) |
08 | if control.Disabled ~ = true then |
09 | control.Disabled = false |
10 | else |
11 | control.Disabled = true |
12 | end |
13 | end ) |
How do I make it to where if you click it again it does Disabled = true?
We can achieve this by an if statement.
An example of an if statement would be:
1 | x = 1 |
2 |
3 | if x = = 1 then |
4 | print ( "This would print" ) |
5 | else |
6 | print ( "This wouldn't, since x is 1." ) |
7 | end |
This if statement would have the output of:
This would print
1 | x = 2 -- Change it, and see what happens. |
2 |
3 | if x = = 1 then |
4 | print ( "This would print" ) |
5 | else |
6 | print ( "This wouldn't, since x is 1." ) |
7 | end |
Now our output would be:
This wouldn't, since x is 1
You try to use if's, and update with your new code. Try to apply it yourself.
Just do control.Disabled = not control.Disabled
This is a way to toggle a Boolean value.
1 | wait(. 03 ) |
2 | local enabled = true |
3 | Player = game.Players.LocalPlayer |
4 | xbc = script.Parent |
5 | control = Player.Backpack.Controls |
6 |
7 | xbc.MouseButton 1 Down:connect( function () -- Remove the "Play" argument. The MouseButton1Down event only passes the X and Y coordinates of the mouse when clicked. If you want to use these, go ahead an re-add them. |
8 | control.Disabled = not control.Disabled |
9 | end ) |