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

Why is this GUI not Tweening to the position?

Asked by
Jephi 42
7 years ago
Edited 7 years ago

So the problem seems to be with line 10, the GUI doesn't seem to tween back to its original position when it's clicked again and I can't figure out why. There are no errors in the output.

local gui = script.Parent.Parent
local hasClicked = false

gui.Sizeout.MouseButton1Down:connect(function()
    if hasClicked ~= true then
        hasClicked = true
        gui:TweenPosition(UDim2.new(0, 0, 0.3, 0), "Out", "Sine")
        gui.Sizeout.Text = "<"
    elseif hasClicked == true then
        gui:TweenPosition(UDim2.new(0, -0.2, 0.3, 0), "In", "Sine") --tweening here not working?
        gui.Sizeout.Text = ">"
    end
end)

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Roblox doesn't allow us to have the numbers be in decimals for the 2 close ones. the (0, 1, 1, 0) 1s represented They can only allow us to use whole numbers.

if anyone wants to jump/improve on that statement, please do

To fix it, you can have {0, -2, 0.3, 0}. Having {-0.2, 0, 0.3, 0} would bring it far right.

Sorry if this is explained a little bit weak.

--with the (0, -2, 0, 0)

local gui = script.Parent.Parent
local hasClicked = false

gui.Sizeout.MouseButton1Down:connect(function()
    if hasClicked ~= true then
        hasClicked = true
        gui:TweenPosition(UDim2.new(0, 0, 0.3, 0), "Out", "Sine")
        gui.Sizeout.Text = "<"
    elseif hasClicked == true then
        gui:TweenPosition(UDim2.new(0, -2, 0.3, 0), "In", "Sine") --tweening here not working?
        gui.Sizeout.Text = ">"
    end
end)

Edit1: you can out the -0.2 in the offset

Ad

Answer this question