How do I change the size of a part to be in contact with another part?

Hello there!

I want to extend the plane to the pink part with a script

I tried setting the size to (pink spart's position - plane's position).Magnitude * 2
But It didn’t work

Edit: the part’s cframe shouldn’t be changed, that way it will also extend the same amount to the opposite side, I could cheat and just set the size independently of the part’s distance but that seems lame.

Help
2 Likes

Here is some results I got:

   local Part = script.Parent
local Ball = workspace.ball

local calculated_distance = (Part.Position - Ball.Position).Magnitude

local Xsize, Ysize, Zsize = Part.Size.X, Part.Size.Y, Part.Size.Z
Part.Size = Vector3.new(Xsize, Ysize, calculated_distance)
Part:PivotTo(CFrame.new(Part.Position, Ball.Position) * CFrame.new(0, 0, -calculated_distance * .5))

PartToBall.rbxl (53.5 KB)

This worked but I couldn’t quite adjust it to my code, because what I’m trying to achieve is this

image

The part should be in contact with every single pink spot, the only thing that should remain the same is the Y axis

You could group it as a model and use bounding box.

1 Like

and according by roblox studio guidlines you should NOT ask someone for writing the whole systems/scripts.

Incase you didn’t read my post, im not asking for the full system, im asking for the logic behind setting the part’s size to another part position. and yes I didn’t think about bounding box, that should work, thank you.

you’re welcome! Just be careful with those thing. I got banned a few times cause of this rule.

1 Like

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