Tween Service [ NEED HELP ]

Is there a way so I can make it like this for Tween Service? Or maybe something similar like this?

local Minimize = false

SettingsButton.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		SettingsFrame.Visible = false and Minimze or true
		local Tween = TweenService:Create(SettingsFrame, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Size = Minimize and UDim2.new(0, 0, 0, 0) or UDim2.new(1, 0, 0.922, 0)})
		Tween:Play()
		local Tween_1 = TweenService:Create(SettingsRounded, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = Minimize and RoundedSize_2 or RoundedSize_1})
		Tween_1:Play()
		wait(2)
		debounce = false
		OpenSettings = true
		Minimize = not Minimize
	end
end)

or should I just stick like this?

local Minimize = false

SettingsButton.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		if not Minimize then
			SettingsFrame.Visible = true
			local Tween = TweenService:Create(SettingsFrame, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Size = UDim2.new(1, 0, 0.922, 0)})
			Tween:Play()
			local Tween_1 = TweenService:Create(SettingsRounded, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = RoundedSize_1})
			Tween_1:Play()
		else
			SettingsFrame.Visible = false
			local Tween = TweenService:Create(SettingsFrame, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Size = UDim2.new(0, 0, 0, 0)})
			Tween:Play()
			local Tween_1 = TweenService:Create(SettingsRounded, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = RoundedSize_2})
			Tween_1:Play()
		end
		wait(2)
		debounce = false
		OpenSettings = true
		Minimize = not Minimize
	end
end)

Because when I use the first code it says TweenService:Create property named ‘Size’ cannot be tweened due to type mismatch (property is a ‘UDim2’, but given type is ‘bool’), but I want to make it shorter script rather than use too many if else, how to do it?

1 Like

You can’t use and or statements inside of tweens if I remember correctly, create a variable outside which has the goal that you’ll be tweening to.

2 Likes

So I think stick with the second script? because I want to check based on bool value

replied to the wrong post above, lol.
I’d stick with the first one just use add a variable above the tween to hold the goal value.

local Minimize = false

SettingsButton.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		local Goal1 = Minimize and UDim2.new(0, 0, 0, 0) or UDim2.new(1, 0, 0.922, 0)
		local Goal2 = Minimize and RoundedSize_2 or RoundedSize_1
		SettingsFrame.Visible = false and Minimze or true
		local Tween_1 = TweenService:Create(SettingsFrame, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {Size = Goal1})
		Tween_1:Play()
		local Tween_2 = TweenService:Create(SettingsRounded, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = Goal2})
		Tween_2:Play()
		task.wait(2)
		debounce = false
		OpenSettings = true
		Minimize = not Minimize
	end
end)
1 Like

Thank you so much for your answer!