Help with scaling a object on a script

Hello, my friends!
So, i’m needing to scale a part using tweenservice, and, i need to scale de Y axis of that part, but, when i try to implement it on a script it is this:

local MetalDoor = script.Parent

local IsOpen = false
local TweenService = game:GetService("TweenService")
local ProximityPrompt = script.Parent:WaitForChild("ProximityPrompt")

local TweenInformation = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

local OpenTween = TweenService:Create(MetalDoor, TweenInformation, {Size = Vector3.new(0.6, 0.1, 4)})

ProximityPrompt.Triggered:Connect(function()
	OpenTween:Play()
end)

Running the game, it rescale it like this:

That is not what i want. It needs to do that rescale:

If someone can help me, i’ll be grateful, thanks!

Try Move the part in the same axis its being sized but divided by 2

1 Like

The issue can be solved by running another tween along with the resizing tween which changes the position. Resizing is done symmetrically on all sides. As @chaxaka said, you can move the part in the same axis it is being sized but divided by 2. Let me know if you need further explaination.

local MetalDoor = script.Parent
local openSize = Vector3.new(0.6, 0.1, 4)
local posOffset = (MetalDoor.Size - openSize)/2

local IsOpen = false
local TweenService = game:GetService("TweenService")
local ProximityPrompt = script.Parent:WaitForChild("ProximityPrompt")

local TweenInformation = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

local OpenTween = TweenService:Create(MetalDoor, TweenInformation, {Size = openSize})
local posTween = TweenService:Create(MetalDoor, TweenInformation, {Position = MetalDoor.Position + posOffset}
-- Try doing "MetalDoor.Position - posOffset" if the door goes downwards instead of upwards
ProximityPrompt.Triggered:Connect(function()
	OpenTween:Play()
	posTween:Play()
end)
1 Like

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