Gui tweening didnt work

Hello,
Currently Im making a menu system which tweens a imagelabel so it could have a style.
But the problem is this

It just prints out but it doesnt work :frowning:
Code:

script.Parent.MouseButton1Click:Connect(function()

print("Clicked!")

print(script.Parent.Parent.Position)

local tween = game:GetService("TweenService")

local twen2 = tween:Create(script.Parent.Parent.Parent.DifficultyMenu,TweenInfo.new(0.7),{Position = UDim2.new({0, 0}, {1, 0})})

twen2:Play()

-- script.Parent.Parent.DifficultyMenu

end)

I accept all helps and opinion!

Thanks for reading :slight_smile:

1 Like

Try this

local tween = game:GetService("TweenService")
local twen2 = tween:Create(script.Parent.Parent.Parent.DifficultyMenu,TweenInfo.new(0.7),{Position = UDim2.fromScale(0, 1)})
script.Parent.MouseButton1Click:Connect(function()
	print("Clicked!")
	twen2:Play()
	print(twen2.PlaybackState)
	-- script.Parent.Parent.DifficultyMenu
end)
1 Like
local button = script.Parent
local ts = game:GetService("TweenService")
local screenGui = script:FindFirstAncestorWhichIsA("ScreenGui")
local menu = screenGui:FindFirstDescendant("DifficultyMenu")

button.MouseButton1Click:Connect(function()
	local tween2 = ts:Create(menu, TweenInfo.new(0.7), {Position = UDim2.new(0, 0, 1, 0)})
	tween2:Play()
	-- script.Parent.Parent.DifficultyMenu
end)

I fixed some of the references, the issue was UDim2.new() doesn’t require table constructors.

1 Like

It worked! But what’s the reason?

The issue was UDim2.new() doesn’t require table constructors.

UDim2.new({0, 0}, {1, 0}) --your code
UDim2.new(0, 0, 1, 0) --fix
1 Like