How to Make a Squash and Stretch Animaiton

Edit: Go to page 14 to see the real help message, so just skip this old message

I’m making a tween animation and I want 2 properties that are the same…

it’s kinda hard to explain so I’m just gonna show my script:

local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, -1, true, 0)

local Part = script.Parent

local newSizeX = Part.Size + Vector3.new(6, 0, 0)
local newSizeY = Part.Size + Vector3.new(0, 6, 0)

local Goal = {Size = newSizeY, Size = newSizeX} -- This is the what am I talking about. This is the "double properties" but it doesn't work.

TweenService:Create(Part, Info, Goal):Play()

Can someone help me please?

Thanks!

try Size.X and Size.Y

althought you could combine those properties into single one

You can’t. At least, as long as you are using tweens you can’t.

-- Renaming default variables for consistency.

local Game = game
local Workspace = workspace

local TweenService = Game:GetService("TweenService")

-- Creating 2 different number values corresponding to the different axes.

local SizeXValue = Instance.new("NumberValue")
local SizeZValue = Instance.new("NumberValue")

local Part = Workspace.Part -- The part to animate.

-- Declaring a function that would set the parts size to the number values defined earlier. 

local function UpdatePartSize()
	Part.Size = Vector3.new(SizeXValue.Value,1,SizeZValue.Value)
end

-- Creating different tween data for the different axes.

local TweenInformationX = TweenInfo.new(
	0.3,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut
)

local TweenInformationZ = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Back,
	Enum.EasingDirection.Out
)

-- Connecting the update size function.

SizeXValue.Changed:Connect(UpdatePartSize)
SizeZValue.Changed:Connect(UpdatePartSize)

-- Creating the tween.

local TweenX = TweenService:Create(SizeXValue,TweenInformationX,{Value = 10})
local TweenZ = TweenService:Create(SizeZValue,TweenInformationZ,{Value = 20})

-- Playing the tween in a loop for easier visibility.

while true do
	SizeXValue.Value = 0
	SizeZValue.Value = 0
	task.wait(1)
	TweenX:Play()
	TweenZ:Play()
end

You are unnecessarily decomposing the vector. Just add a single vector of 6, 6, 0 instead of doing it separately. It will mathematically be the same.

2 Likes

Well in this case you kind of can..

local Part = script.Parent
local TweenService = game:GetService(“TweenService”)
local Info = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, -1, true, 0)

local Goal = {Size = Part.Size + Vector3.new(6, 6, 0)}
TweenService:Create(Part, Info, Goal):Play()

theres literally no reason why u are adding two seperate vectors to Part.Size, just do
Part.Size + Vector3.new(6, 6, 0) as your goal

5 Likes

TweenService requires a dictionary of property-value pairs. The valid form is:
local Goal = {Size = Part.Size + Vector3.new(6, 6, 0)}

Buddy, I didn’t ask, I only gave him solution on masking two Vector3’s into one and using that as a goal.

Just two different ways of doing the same thing. Don’t get all excited.. buddy.

Are you trying to preserve order? Or, are you just adjusting the properties in one move? If the former, I can expand. If you’re simply looking to tween both X and Y dimensions in the same tween, the others have answered your question.

Buddy, I didn’t ask for your help, I replied to the OP about masking two Vector3’s.

What the hell do you mean both ways? we said the exact same thing except you spoonfed him with more of the code.

What is wrong with you? Do you think this is a debate. You posted the same thing I did worded differently. Clearly you need the last word here also.. :rofl::rofl: PM me if you want to talk about it, I’m more than sure you will not.

Damn people, I’m braindead to scripting. Thanks for helping me!

Dramtic Credits:

Thanks for Microlosfto, JackWorhee, Denneisk, 2112Jay, ChiDj123, Trigophi for helping me to understand that I need to get iq test for boblox studio scripting online!

Hi guys,

I want to say thanks for the help. But I realized I kinda messed up explaining the style I was going for. I need the part to that bouncy, squishy animation - It’s called Squash and Stretch, I think.

The current animation is super duper good, but it’s not quite I wanted.. :frowning:

This is my inspiration from “scary horro game”. Pay attention for the “Submit” button animation:

Da Video

Thanks again for helping me, I’m literally learning from this!

Well that looks a bit more complicated, or not..
When creating a tween to move something to a location, you can place the same part as a temporary at the desired spot. Copy its position and orientation for the tween, then remove the temporary part. You may want to test a few spots first to see what you like.

The script to move to the temp part.

local TweenService = game:GetService("TweenService")
local part = script.Parent
local target = workspace:WaitForChild("TargetPart")

local info = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local goal = {CFrame = target.CFrame}

local tween = TweenService:Create(part, info, goal)
tween:Play()

Something like what the finished script would look like.

local TweenService = game:GetService("TweenService")
local part = script.Parent

local info = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local targetCFrame = CFrame.new(0, 10, 0) * CFrame.Angles(0, math.rad(90), 0)

local tween = TweenService:Create(part, info, {CFrame = targetCFrame})
tween:Play()

In this case you would want to flip the temp part, so the tween moves as you wish.

You can do this with sine and cosine to create the circular motion you’re going for, here’s an example:

local part = Instance.new("Part")
part.Anchored = true
part.Position = Vector3.new(0, 5, 0)
part.Parent = workspace

local sine = 0

while true do 
	sine += task.wait()
	
	part.Size = Vector3.new(6 + 3 * math.cos(sine * 8), 6 + 3 * math.sin(sine * 8), 1)
end

Then you can offset the cosine/sine by adding (i.e sine * 8 becomes sine * 8 + number) to it.

2 Likes

Yo man, thanks for helping me :smiling_face_with_tear:

and thanks for all the others who also tried to help me :smiling_face_with_tear:

I hope for you a wonderful happy new year!

Oh, and, thanks again

1 Like

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