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

Double clicking a gui?

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?

4 comments

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?

0

Remove "Play" in line 7 because MouseButton1Down does not have any arguments.

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.

0

Thanks guys I was able to make it work.

2 answers

✓ Accepted answer

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.

4 comments

0

That's what I came up with and it stopped working all together.

0

"if Disabled == false then Disabled = false else Disabled = true end" is what you now have, kingalpha1

0

Hm...I'm stuck..

0

Change line 8 from ~= to "=="

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)

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