I’m trying to create a sliding door and I’m trying to move multiple parts using welds with tweens as shown in the image
But for some reason the detail parts don’t move with the main parts (see second picture)
Here’s my code:
local mainPart1 = script.Parent.door1.PrimaryPart
local mainPart2 = script.Parent.door2.PrimaryPart
local detail1 = script.Parent.door1.door1Detail
local detail2 = script.Parent.door2.door2Detail
local detector = script.Parent.detector
local tweenService = game:GetService('TweenService')
local runService = game:GetService('RunService')
local doorSize1 = Vector3.new(mainPart1.Size.X + detail1.Size.X + 0.5, mainPart1.Size.Y, mainPart1.Size.Z)
local doorSize2 = Vector3.new(mainPart2.Size.X + detail2.Size.X + 0.5, mainPart2.Size.Y, mainPart2.Size.Z)
some = function(t, func)
local isTrue = false
for i, v in ipairs(t) do
local bool = func(v)
if bool then isTrue = true end
end
print(isTrue)
return isTrue
end
local goals = {
["goal1First"]={
["Position"]=Vector3.new(
mainPart1.Position.X + doorSize1.X,
mainPart1.Position.Y,
mainPart1.Position.Z
)
},
["goal1End"]={
["Position"]=Vector3.new(
mainPart1.Position.X - doorSize1.X,
mainPart1.Position.Y,
mainPart1.Position.Z
)
},
["goal2First"]={
["Position"]=Vector3.new(
mainPart2.Position.X - doorSize2.X,
mainPart2.Position.Y,
mainPart2.Position.Z
)
},
["goal2End"]={
["Position"]=Vector3.new(
mainPart2.Position.X + doorSize2.X,
mainPart2.Position.Y,
mainPart2.Position.Z
)
}
}
local info = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local isOpen = false
function createTweens(close)
if not close then
tweenService:Create(mainPart1, info, goals['goal1First']) :Play()
tweenService:Create(mainPart2, info, goals['goal2First']):Play()
end
end
detector.Touched:Connect(function(part)
if not part.Parent:FindFirstChildOfClass('Humanoid') and not isOpen then return end
isOpen = true
createTweens(false)
end)
If anyone knows how to fix this, it would be much appreciated