Is it possible to resize a part and have its attachments resize along with it?

Greetings,

I am trying to tween a part in such a way that the attachments it contains spread out along with it getting bigger like they do when you resize it in studio. Is this even possible?

Thanks for your time

1 Like

Yes it is possible to make it spread along with the part but you need to do this manually. This is kinda an interesting questions so I did a little experiment on the thing and yea, it seems to work.

It’s just a bit of math stuff.

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

local TweenSize = Vector3.new(10.222, 18, 22) -- Part size + tween size. (Change it to whatever you want)

local ResultX = Attachment.Position.X ~= 0 and (Attachment.Position.X > 0 
	and Attachment.Position.X + TweenSize.X/2 or Attachment.Position.X - TweenSize.X/2)
	or 0
local ResultY = Attachment.Position.Y ~= 0 and (Attachment.Position.Y > 0 
	and Attachment.Position.Y + TweenSize.Y/2 or Attachment.Position.Y - TweenSize.Y/2)
	or 0
local ResultZ = Attachment.Position.Z ~= 0 and (Attachment.Position.Z > 0 
	and Attachment.Position.Z + TweenSize.Z/2 or Attachment.Position.Z - TweenSize.Z/2)
	or 0

TweenService:Create(Part, TweenInfo.new(3), {Size = Part.Size + TweenSize}):Play()
TweenService:Create(Attachment, TweenInfo.new(3), {Position = Vector3.new(
	ResultX,
	ResultY,
	ResultZ
	)
}):Play()

With the math stuff.

Without the math stuff.

9 Likes

This doesn’t really seem to work when I put it in a loop. Do you know how I can make it work?

1 Like