How to tween UI size

Hello, I’m trying to figure out how to tween ui that gets bigger and smaller, I attempted the following line of code and was greeted with the error below:

Tween:Create(Eye,TweenInfo.new(0.35,Enum.EasingStyle.Sine,Enum.EasingDirection.Out) , {Size = {0, 160},{0, 130}}):Play()

The Error: “Unable to cast to Dictionary”

I’ve tried applying it as UDim2 rather than “Size” and it still has the same outcome. I’m unsure what to do or where to go from here.
If anybody can tell me how to properly tween UI, that’d mean the world.

2 Likes

the only error i can see is that the Size property is a UDim2 not a table

Tween:Create(Eye,TweenInfo.new(0.35,Enum.EasingStyle.Sine,Enum.EasingDirection.Out) , {Size = UDim2.new(0, 160, 0, 130)}):Play()
1 Like

I’m unsure why it is but roblox requires the tweening of Gui Objects to be done using TweenSize() or TweenPosition(); however, all other properties can be tweened using tween service.

You may find this useful:
https://create.roblox.com/docs/reference/engine/classes/GuiObject#TweenSize

Here is an example of how it may be used in code:

Eye:TweenSize(Udim2.new(0, 160, 0, 130), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, Time)
1 Like

You can tween UDim2 values with TweenService, including the size and position of Gui objects

3 Likes

So weirdly enough, I’m doing it this way, and the error is gone, but the UI isn’t moving???

I’ve done position before, but never size

could you post the full script or the part where you do stuff with the ui

1 Like

As in where the UI is located?

the full script that tweens the ui and the location of the ui would be helpful too

1 Like

it’s a bit of a chunk but sure here:

UIS.InputBegan:Connect(function(input, isTyping)	-- Six Eyes Activate
	if isTyping or Humanoid.FloorMaterial == Enum.Material.Air then return end
	if input.KeyCode == Enum.KeyCode.Z and Debounce == false and SixEyesVal == false then
		Debounce = true
		SixEyesVal = true
		Char.HumanoidRootPart.Anchored = true
		local SEF = game.ReplicatedStorage.GojoAssets.Effects.SixEyes
		local SixEyeGUI = game.ReplicatedStorage.GojoAssets.Effects.SixEyes.SixEyesScreen:Clone()
		SixEyeGUI.Parent = game.Players.LocalPlayer.PlayerGui
		Anim.AnimationId = SixEyeOn
		local LiveAnim = Char.Humanoid:LoadAnimation(Anim)
		LiveAnim:Play()
		task.wait(1.2)
		Event:FireServer("SixEyesOn")
		task.wait(0.3)
		local Bloom = SEF.ScreenEffects.SE_Bloom
		local Blur = SEF.ScreenEffects.SE_Blur
		local Color = SEF.ScreenEffects.SE_Color
		Bloom.Parent = game.Lighting
		Blur.Parent = game.Lighting
		Color.Parent = game.Lighting
		Tween:Create(Bloom,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {Intensity = 1}):Play()
		Tween:Create(Bloom,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {Size = 200}):Play()
		Tween:Create(Bloom,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {Threshold = 0.6}):Play()
		Tween:Create(Blur,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {Size = 5}):Play()
		Tween:Create(Color,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {Brightness = 0.1}):Play()
		Tween:Create(Color,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {Saturation = -0.3}):Play()
		Screen()
		for i,v in pairs(game.Workspace:GetDescendants()) do
			if v.Name == "Body Colors" and v.Parent.Name ~= script.Parent.Name then
				local Weld = SEF.Weld:Clone()
				local CursedAura = SEF.CursedEnergy:Clone()
				local CursedHighlight = SEF.SixEyeHighlight:Clone()
				Weld.Parent = v.Parent.Torso
				CursedAura.Parent = game.Workspace
				CursedAura.Position = v.Parent.HumanoidRootPart.Position
				Weld.Part0 = CursedAura
				Weld.Part1 = v.Parent.Torso
				CursedHighlight.Parent = v.Parent
				Tween:Create(CursedHighlight,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {FillTransparency = 0.3}):Play()
				table.insert(SEDelTable, Weld)
				table.insert(HighlightTable, CursedHighlight)
				table.insert(VFXDelTable, CursedAura)
			end
		end
		task.wait(1)
		Tween:Create(SixEyeGUI.Eye,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut) , {ImageTransparency = 0}):Play()
		while true do
			Tween:Create(game.Players.LocalPlayer.PlayerGui.SixEyesScreen.Eye,TweenInfo.new(0.35,Enum.EasingStyle.Sine,Enum.EasingDirection.Out) , {Size = UDim2.new(0, 160, 0, 130)}):Play()
			task.wait(1)
			Tween:Create(game.Players.LocalPlayer.PlayerGui.SixEyesScreen.Eye,TweenInfo.new(0.35,Enum.EasingStyle.Sine,Enum.EasingDirection.Out) , {Size = UDim2.new(0, 146,0, 116)}):Play()
		end
		task.wait(1)
		Char.HumanoidRootPart.Anchored = false
		Debounce = false
	end
end)

I apoligize if it’s a massive mess, I’ve been told my way of coding is super hard to understand

Originally the UI size up and down was going to be done via called function but I decided to try and stick it in a while true loop, might have to revert, unsure. Just trying things out at this point.

the issue might be that you didnt add a wait after the second tween so when the second tween plays the first one does too

1 Like

let me try that real quick, let you know how that goes

Yea that was it. That’s mildly upsetting but at least it’s working now. Thank you so much

1 Like

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