Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make unanchored parts stay in a box?

Asked by 2 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

So I have a box filled with unanchored cubes and I tween the box to move to another destination. However, the unanchored cubes in the box do not move along with the box i am tweening to move. Once the box has reached its destination i want the unanchored cubes inside the box to stay unanchored. So what can I do to keep unanchored cubes inside of a box tat is moving?

1 answer

Log in to vote
1
Answered by 2 years ago

maybe you can weld them to the box while the tween is playing then un-weld them when the tween is over.

like this:

--put the cubes in a folder or model

local cubes = --the model or folder the cubes are in
local box = --the box you're trying to tween


for _, cube in pairs(cubes:GetChildren()) do
local weld = Instance.new("Weld")
weld.Parent = cube
weld.Part0 = cube 
weld.Part1 = box
end

--your tween code here

--to destroy the welds


for _,v in pairs(cubes:GetChildren()) do
if v:IsA("Weld") then -- checks if it's a weld
v:Destroy()--destroys it


end
end



Ad

Answer this question