Tweening Issue with block grow / shrink

Hi,

I am having a strange issue tweening a blocks size on the X axis only, I want it to grow and shrink but for some reason my code does this but also it does an odd shrink/move between see link to video as hard to explain.

Thanks for any help you can give.

local TweenService = game:GetService("TweenService");
local Part = script.Parent
local PartStart = script.Parent

local TweenInfo = TweenInfo.new(1 , Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, true, 0)

-- grow
local Goal1 = {
	Size = Part.Size + Vector3.new(5, 0, 0),
	CFrame = Part.CFrame * CFrame.new(5 / 2, 0, 0)
}

-- shrink
local Goal2 = {
	Size = Vector3.new(PartStart.Size.X, 0, 0),
	CFrame = CFrame.new(PartStart.Position.X, PartStart.Position.Y, PartStart.Position.Z)
}

local myTween1 = TweenService:Create(Part, TweenInfo, Goal1);
local myTween2 = TweenService:Create(Part, TweenInfo, Goal2);

while true do
	myTween1:Play()
	myTween1.Completed:Wait()	
	myTween2:Play()
	myTween2.Completed:Wait()	
end

An issue I notice is that variable PartStart is just set to the part; not any actual property. This means that when PartStart is used it won’t have the original values but will instead just store the part with all its current properties. To fix this, you will need to make two variables that save the actual properties of the part. Since you use both the Size and CFrame in Goal2, save the Size and CFrame like this:

local StartSize = script.Parent.Size
local StartCFrame = script.Parent.CFrame

Then when you’re defining the properties for Goal2, use those variables:

-- shrink
local Goal2 = {
	Size = StartSize
	CFrame = StartCFrame
}
1 Like

Does the part start off rotated by any chance?

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