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)
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)