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

Double clicking a gui?

Asked by 10 years ago
01wait(.03)
02local enabled = true
03Player = game.Players.LocalPlayer
04xbc = script.Parent
05control = Player.Backpack.Controls
06 
07xbc.MouseButton1Down:connect(function(Play)
08    if control.Disabled ~= true then
09        control.Disabled = false
10    else
11        control.Disabled = true
12    end
13end)

How do I make it to where if you click it again it does Disabled = true?

0
Okay! You're right there, but let's take a look. On line 8 you say if the Disable isn't on, turn it off? Why would you turn something thats already off, off? AmericanStripes 610 — 10y
0
Remove "Play" in line 7 because MouseButton1Down does not have any arguments. EzraNehemiah_TF2 3552 — 10y
0
@LordDragonZord Actually, MouseButton1Down does, it has two, X and Y. However he doesn't need them, so he **could** remove it, but doesn't need to. AmericanStripes 610 — 10y
0
Thanks guys I was able to make it work. kingalpha1 15 — 10y

2 answers

Log in to vote
1
Answered by 10 years ago

We can achieve this by an if statement.


Let's take a look at if's.

An example of an if statement would be:

1x = 1
2 
3if x == 1 then
4    print("This would print")
5else
6    print("This wouldn't, since x is 1.")
7end

This if statement would have the output of:

This would print


Let's take a look at the same script, but play with it some more.

1x = 2 -- Change it, and see what happens.
2 
3if x == 1 then
4    print("This would print")
5else
6    print("This wouldn't, since x is 1.")
7end

Now our output would be:

This wouldn't, since x is 1


Now that we understand if's, let's apply it to your code.

You try to use if's, and update with your new code. Try to apply it yourself.

0
That's what I came up with and it stopped working all together. kingalpha1 15 — 10y
0
"if Disabled == false then Disabled = false else Disabled = true end" is what you now have, kingalpha1 User#2 0 — 10y
0
Hm...I'm stuck.. kingalpha1 15 — 10y
0
Change line 8 from ~= to "==" AmericanStripes 610 — 10y
Ad
Log in to vote
3
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

Just do control.Disabled = not control.Disabled This is a way to toggle a Boolean value.

1wait(.03)
2local enabled = true
3Player = game.Players.LocalPlayer
4xbc = script.Parent
5control = Player.Backpack.Controls
6 
7xbc.MouseButton1Down: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
9end)

Answer this question