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 9 years ago
wait(.03)
local enabled = true
Player = game.Players.LocalPlayer
xbc = script.Parent
control = Player.Backpack.Controls

xbc.MouseButton1Down:connect(function(Play)
    if control.Disabled ~= true then
        control.Disabled = false
    else
        control.Disabled = true
    end
end)

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 — 9y
0
Remove "Play" in line 7 because MouseButton1Down does not have any arguments. EzraNehemiah_TF2 3552 — 9y
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 — 9y
0
Thanks guys I was able to make it work. kingalpha1 15 — 9y

2 answers

Log in to vote
1
Answered by 9 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:

x = 1

if x == 1 then
    print("This would print")
else
    print("This wouldn't, since x is 1.")
end

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.

x = 2 -- Change it, and see what happens.

if x == 1 then
    print("This would print")
else
    print("This wouldn't, since x is 1.")
end

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 — 9y
0
"if Disabled == false then Disabled = false else Disabled = true end" is what you now have, kingalpha1 User#2 0 — 9y
0
Hm...I'm stuck.. kingalpha1 15 — 9y
0
Change line 8 from ~= to "==" AmericanStripes 610 — 9y
Ad
Log in to vote
3
Answered by
Tkdriverx 514 Moderation Voter
9 years ago

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

wait(.03)
local enabled = true
Player = game.Players.LocalPlayer
xbc = script.Parent
control = Player.Backpack.Controls

xbc.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.
    control.Disabled = not control.Disabled
end)

Answer this question