How to tween size a part in only one direction

Let’s say I am trying to make a saber and want it to be activated which can be done by resizing the light part by doing that I need to tween it. But when I do that it resizes in both directions instead in 1. How can I possibly fix that?
Here is the script that could possibly be useful:

local Tool = script.Parent.Parent
local Saber = Tool.Saber
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Handle = Tool.Handle
local Tween = game:GetService("TweenService")
local Info = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false
)
local ActivatedTable = {
	Size = Vector3.new(Saber.Position.X + 5, 0, 0)
}
local DeActivatedTable = {
	Size = Vector3.new(0.3, 0.3, 1.5)
}
local ActivatedTween = Tween:Create(Saber, Info, ActivatedTable)
local DeActivatedTween = Tween:Create(Saber, Info, DeActivatedTable)

Tool.Equipped:Connect(function()
	Player.PlayerGui.SaberControls.Enabled = true
	UIS.InputBegan:Connect(function(input)
		if input.KeyCode == Enum.KeyCode.Q then
			print("Opening")
			ActivatedTween:Play()
		end
		UIS.InputBegan:Connect(function(input)
			if input.KeyCode == Enum.KeyCode.E then
				print("Closing")
				DeActivatedTween:Play()
			end
		end)
	end)
end)

Tool.Unequipped:Connect(function()
	Player.PlayerGui.SaberControls.Enabled = false
end)


2 Likes

This post should help you tween in one direction… play with the position property:

1 Like

In addition to tweening its size, you need to to tween its position, wherein half the desired size must be added to its current position.

local Enumeration = Enum
local Game = game
local Workspace = workspace
local TweenService = Game:GetService("TweenService")

local Part = Instance.new("Part")
Part.Anchored = true
Part.Size = Vector3.new(2, 1, 2)
Part.Parent = Workspace

local Tween = TweenService:Create(Part, TweenInfo.new(10, Enumeration.EasingStyle.Linear, Enumeration.EasingDirection.Out), {Position = Part.Position + Vector3.new(5, 0, 0), Size = Part.Size + Vector3.new(10, 0, 0)})
Tween:Play()

https://gyazo.com/3730ae1d2b74c918dcca71dcb8cc83da

4 Likes
local ActivatedTable = {
	Size = Vector3.new(Saber.Position.X + 5, 0, 0)
	Position = Saber.Position - Vector3.new(5, 0, 0)
}

By changing the position too

It just teleports back to the place where it’s at when the tool is in workspace

Tried that it teleports the saber to the place where it’s at when it’s in workspace