Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

EDITED how would I make a tween script to grow every part relative to their own size?

I want to grow every part named "GasPart". But it grows every part with this name to the same size. These parts are all different sizes, so could they all grow the same amount on the y axis?

for k,n in pairs(game.Workspace:GetChildren()) do

	if n.Name == "GasPart" then     
		SizeOfX = n.Size.x

	end
end

local TweenService = game:GetService("TweenService")
local GasPart = game.Workspace.GasPart
local y = 17.051
local z = 11.5
local x = SizeOfX
	
local Info = TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,
	-1,
	true,
	0   
)

local Goals = {
	Size = Vector3.new(x, y, z);
}

for k,n in pairs(game.Workspace:GetChildren()) do

	if n.Name == "GasPart" then     
		local exampletween = TweenService:Create(n, Info, Goals)
		exampletween:Play() 
	end
end

1 answer

✓ Accepted answer

You'll need to put the goal of the tweening inside of the for loop so that you can get the relative size to each part.

I'd create a variable with the amount that I want to be added and then inside of the for loop add that to the current size in the goal.

local AmountToAdd = Vector3.new(10, 10, 10)

for k,n in pairs(game.Workspace:GetChildren()) do
	if n.Name == "GasPart" then  
	
		local Goals = {
			Size = n.Size + AmountToAdd 
		}
	
		local exampletween = TweenService:Create(n, Info, Goals)
		exampletween:Play()
	end
end

1 comment

0

Thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.