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

Why is this GUI not Tweening to the position?

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

✓ Accepted answer

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

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