How do I resize a part with attachments?

I’m resizing a part through scripts, and I get this issue. The green dots are the attachments.
This is the original part.


When I resize with the resize tool.

When I resize it with scripts.

The attachments stay in the same place, instead of moving relative to the parts size. How can I fix this?

1 Like

You would want to set the attachments position equivalent to the size.

Thats what i’m trying to do.

wafadawwe

Same way as you resize Attachments for R6 scaling, decrease their CFrame positioning with a scale factor the same as the resize factor:

2 Likes

Here’s an example if you need.

script.Parent.Attachment.Position = script.Parent.Size.X

Send me the script you use and I can help you with so.

1 Like

Record the previous CFrame and the size of the attachment. After resizing, multiply the CFrame’s position by the OldSize/NewSize. I think this should work.

@LuaCoold that won’t do any at all
@SubtotalAnt8185 the part is going to be resizing in a loop, so constantly
@dthecoolest how would I use that script for attachments?

Attachments actually work similarly to welds I have put an example and code in my tutorial,

So you can just replace C0 with Attachment0.CFrame and C1 with Attachment1.CFrame

		for i,Accessory in pairs(Player.Character:GetChildren()) do
			if Accessory:IsA("Accessory") == false then continue end
			
-			Accessory.Handle.AccessoryWeld.C0 = --Instead of this
+			Accessory.Handle.Attachment0.CFrame = --replace it with Attachment0
			Accessory.Handle.AccessoryWeld.C1 = CFrame.new((Accessory.Handle.AccessoryWeld.C1.Position * Percent)) * (Accessory.Handle.AccessoryWeld.C1 - Accessory.Handle.AccessoryWeld.C1.Position)
			Accessory.Handle.Mesh.Scale *= Percent	
		end

How do I get the percent? The part is going to be resizing unpredictably in a loop. Also not uniformly, so it’s going to be resized in all kinds of directions.

Percent is actually the percentage change, can get the initial value final value and use the formula below to get the decimal percentage.

image

Depending on the size x,y,z axis you may need to multiply the xyz axis of the Attachment0 Position by a different percentage.

1 Like

This is the part that I’m going to be resizing.


And uh what is “relative change”? and what does the initial and final value mean?
(sorry im dumb at math)

I’ll do it for you, luckily this problem is simple enough to do on a fresh base plate.

local part = script.Parent

local attachment = part.Attachment

local initialPosition = attachment.Position
local initialSize = part.Size

while true do
	local newSize = part.Size
	local scaleFactorFromOriginal = (newSize)/initialSize
	
	attachment.Position = initialPosition*scaleFactorFromOriginal
	task.wait()
end

Result:

4 Likes

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