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

Help with Draggable Gui?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

When I click a textbutton draggable goes true on the frame. I want to make it when I click it again, all those trues turn to false.

script.Parent.MouseButton1Down:connect(function()
        script.Parent.Parent.Draggable = true
        script.Parent.Parent.Active = true

end)

2 answers

Log in to vote
2
Answered by 8 years ago

To switch between Draggable or not we can use If statement andelse.

script.Parent.MouseButton1Down:connect(function()--Function Listen for the MouseButton1Down Event.
      if script.Parent.Parent.Draggable == false then--Check If the Draggable Property is false, if It is then.
        print(script.Parent.Parent.Draggable)
        script.Parent.Parent.Draggable = true--Turn Its True
    else--If it wasn't Draggable property wasn't false then
        print(script.Parent.Parent.Draggable)
        script.Parent.Parent.Draggable = false--Turn it false.

        script.Parent.Parent.Active = true
    end
end)

Ad
Log in to vote
2
Answered by
dyler3 1510 Moderation Voter
8 years ago

As for switching between Draggableand not, we can simply use the 'not' thingy.

So to fix your code, you simply need it to look like this.

script.Parent.MouseButton1Down:connect(function()
    script.Parent.Parent.Draggable = not script.Parent.Parent.Draggable --If it's true, it switches to false, if false, it switches to true.
    script.Parent.Parent.Active = script.Parent.Parent.Draggable
end)

So anyways, your code should work now. If you have any further problems/questions, please leave a comment below. Hope I helped :P

-Dyler3

Answer this question