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

Why does my gui only tween once and then stops working?

Asked by 6 years ago

I'm trying to make a gui that changes positions using the Tweenposition function but it only works once and won't work again until my player respawns.

Local script located in textbutton:

local inuse = false

script.Parent.MouseButton1Click:connect(function()
    if inuse == false then
        inuse = true
        script.Parent.Parent:TweenPosition(UDim2.new(0, 350,0, 230))
        wait(1.5)
    end

end)

script.Parent.MouseButton1Click:connect(function()
    if inuse == true then
        inuse = false
        script.Parent.Parent:TweenPosition(UDim2.new(0, 10,0, 230))
        wait(1.5)
    end

end)

Thanks!

1 answer

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago
local inuse = false

script.Parent.MouseButton1Click:connect(function()
    if inuse == false then
            inuse = true
            script.Parent.Parent:TweenPosition(UDim2.new(0, 350,0, 230))
    else
        inuse = false
            script.Parent.Parent:TweenPosition(UDim2.new(0, 10,0, 230))
    end
end)
Ad

Answer this question