How to make this TweenService alternative to :Resize() grow left instead of right

I found this article which has an amazing script that works perfectly as a tweened alternative to :Resize(). However, a note in the script says to “change the + to - if you want it to extend to the right”. I have tried every possible combination of changing + to - (since the note is not specific about which ones to change) cause I need it to extend to the right. Am I missing something… please help.

local TweenService = game:GetService("TweenService")
local part = game.Workspace.Part
local SizeX = part.Size.X + 50

local info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1)
local properties = {
	Size = Vector3.new(SizeX, part.Size.Y, part.Size.Z),
	Position = Vector3.new((part.Position.X + (-1*(SizeX)/2) + (part.Size.X/2)), part.Position.Y , part.Position.Z)
    -- change the + to - if you want it to extend to the right
}
local tween = TweenService:Create(part, info, properties)
tween:Play() -- this is the same as doing part:Resize(Enum.NormalId.Left, 50)
1 Like

Changing the -1 to 1 and multiplying the part.Size.X/2 part by -1 works perfectly for me

I would honestly just simplify out the negative so you can have a single number determining what its gonna do

For example:

Position = Vector3.new(part.Position.X + -1 * (SizeX/2 - part.Size.X/2), part.Position.Y , part.Position.Z)

-1 is left, 1 is right just like the original script is supposed to function

1 Like

Works great! One more question. When the player is walking while the flag is growing or the idle animation players or anything it repositions itself (obviously since the tween is changing the position). How can I make it so it can not move from the original position on the tool? I hope that makes sense if not I can provide a visual demonstration.

How it it set up? You might be able to use a weld and tween the C0 instead

It is just attached to another part via a weld constraint.

Here is the copy of the starter tool. Tool - Roblox

I would switch it to a normal weld, set the correct offset using C1 then tween the C0 just like the position but with cframes

How do I even insert a normal weld?

Are you doing it in a script or in studio?

In studio {extra words to meet limit}.

I would use the command bar to add it because studio will mess it up plus the property is hidden

local weld = Instance.new("Weld")
weld.Part0 = yourPart0
weld.Part1 = yourPart1
weld.C1 = yourPart1.CFrame:Inverse()*yourPart0.CFrame
weld.Parent = parent

Just paste that into the command line after deleting the weldconstraint

Alright got it in, so how would I modify the existing code to work for the weld then?

Youll have to mess with it a bit but basically just change Position to C0 and Vector3 to CFrame
You might have to change it from the x to the y or z of the cframe.new though

So would I only move the weld or both?

Oh right youd need to separate it to a new tween, so do it for both

Alright I will do that and let you know if I have any more questions, thanks.