UI tween doesn't work!

I have this tweening script but it doesn’t work. I’ve added comments if that helps! Thanks for helping!

Snippet of code

SettingButton.MouseButton1Down:Connect(function()
	local FrameX = SettingFrame.Position.X
	local FrameY = SettingFrame.Position.Y
	
	local Up = -370 -- Do not change
	local tween = ts:Create(SettingFrame, info, {Position = UDim2.new(FrameX.Scale, FrameX.Offset, FrameY.Scale, FrameY.Offset == Up)}) -- This doesn't work
	
	SettingFrame.Visible = true
	
	tween:Play()
	tween.Completed:Connect(function()
		SettingFrame.ExitButton.Visible = true
	end)
end)

SettingFrame.ExitButton.MouseButton1Down:Connect(function()
	local FrameX = SettingFrame.Position.X
	local FrameY = SettingFrame.Position.Y
	
	SettingFrame.ExitButton.Visible = false
	
	local tween = ts:Create(SettingFrame, info, {Position = UDim2.new(FrameX.Scale, FrameX.Offset, FrameY.Scale, FrameY.Offset == 0)}) -- this works but why it doesn't work with negatives?
	tween:Play()
	
end)

BackButton.Visible = false

PlayButton.MouseButton1Down:Connect(function()
	if Settings["Gui Position Tweens"] then
		for i, Buttons in pairs(MainFrame:GetChildren()) do
			
			if Buttons:IsA("TextButton") or Buttons:IsA("ImageButton") then
				local ButtonPosX =  Buttons.Position.X
				local ButtonPosY = Buttons.Position.Y
				
				UILISTLAYOUT.Parent = Gui.Parent
				
				local Animate = Num --Don't change
				
				
			local tween = ts:Create(Buttons, info, {Position = UDim2.new(Buttons.Position.X.Scale, ButtonPosX.Offset - Animate, Buttons.Position.Y.Scale, ButtonPosY.Offset)}) -- Replace - with + if you want the button to go right or - to go left
				tween:Play()
								
				tween.Completed:Connect(function()
					MainFrame.Visible = false
					BackButton.Visible = true
				end)
				
			end
			
		end
		
	else
		
		MainFrame.Visible = false
		
	end
	
end)

1 Like

The == is a comparator check, not setting a value. Easy typo to make and miss when checking.

3 Likes

This chunk of code works. It’s using the double equal signs.

i think what he means is that you arent supposed to be using the double equal signs since that is used for comparing and checking two values. you would have to use the variable itself (Up) to set the value of the UDim2 youre trying to define

Could you try replacing FrameY.Offset == Up in the first UDim2 line with just Up instead? i think you only need the variable you want to tween to instead of trying to set a value to it when attempting to tween the ui

1 Like

Ah, I see, I’ll replace it, thanks for the help!

no problem! make sure to mark @BadDad2004 response as a solution if it works

1 Like

sorry for the late reply but dont forget to replace FrameY.Offset == 0 with just 0 instead for the same reasons above if you haven’t already

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.