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

How to give textbox/click detector multiple functions?

Asked by
kepiblop 124
4 years ago
Edited 4 years ago

I tried to make a text box that would have multiple functions. For a example you click it once it will go to the right you click it again it will go to the left with 1 button the problem is that when i try to do it i click it it goes to the left and i click it again it stays at the left here is what i tried.

script.Parent.MouseButton1Down:Connect(function()
    script.Parent.Position = UDim2.new(0.727, 0, 0.401, 0)
end)

script.Parent.MouseButton1Down:Connect(function()
    script.Parent.Position = UDim2.new(0.019, 0, 0.397, 0)
end)

Any help is appreciated.

0
You could have a variable that holds a state and changes it based on what the last click did. For example you could say that state = "left" and if state = "left" then move it right and assign "right" to state indicating its last move. msuperson24 69 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

What you could have is a bool variable for example

local bool = false

script.Parent.Parent.TextButton.MouseButton1Click:Connect(function()
    if bool == false then
        script.Parent.Parent.Frame.Position = UDim.new(0,727, 0, 0.401, 0)
        bool = true
    elseif bool == true then
        script.Parent.Parent.Frame.Position = UDim2.new(0.019, 0, 0.397, 0)
    end
end)
0
what if i could want to do 3 more functions like i can press it once it goes right again left and if i press it once again it goes up and left and again it goes down and right sorry if i sound confusing kepiblop 124 — 4y
0
After line 8, Type in bool = false CRAZYQUACKY84 113 — 4y
0
Thank you, you are very helpful kepiblop 124 — 4y
Ad

Answer this question