For me if I wanted to animate parts I usually use TweenService for this without adjusting the anchor parts to false. You can also adjust the CFrame with XYZ axis so that it doesn’t move the whole curtain.
local left = game.Workspace.["Your Left Curtain"]
local right = game.Workspace.["Your Right Curtain"]
local CD = game.Workspace.["Your Click Detector"]
local db = false -- added debounce to open and close curtains, Also helps to avoid spam clicking / interacting the curtain
local tweenInfo = TweenInfo.new(
0.6, -- You can adjust the time animation to your likings
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
--// Go to workspace, check your left and right curtain and its size, copy paste its axis.
local newSize = Vector3.new(1, 14, 5) -- Shrink your curtain to what you want to open
local oldSize = Vector3.new(1, 14, 16) -- I added this if you want to close the curtain
local Goleft = {
CFrame = left.CFrame * CFrame.new(0, 0, (newSize.Z - left.Size.Z)/2), -- Use (newSize.Z - left.Size.Z)/2 to change the size of curtain
Size = newSize
}
local Goright = {
CFrame = right.CFrame * CFrame.new(0, 0, (newSize.Z - right.Size.Z)/-2), -- I added -2 to keep it on the right direction.
Size = newSize
}
local leftclose = {
CFrame = left.CFrame * CFrame.new(0, 0, (oldSize.Z - left.Size.Z)/2), -- Use (newSize.Z - left.Size.Z)/2 to change the size of curtain
Size = oldSize
}
local rightclose = {
CFrame = right.CFrame * CFrame.new(0, 0, (oldSize.Z - right.Size.Z)/-2), -- I added -2 to keep it on the right direction.
Size = oldSize
}
local Play = game:GetService("TweenService"):Create(left, tweenInfo, Goleft)
local Play1 = game:GetService("TweenService"):Create(right, tweenInfo, Goright)
local Play2 = game:GetService("TweenService"):Create(left, tweenInfo, leftclose)
local Play3 = game:GetService("TweenService"):Create(right, tweenInfo, rightclose)
CD.MouseClick:Connect(function()
if db == false then
--// Open Curtain
Play:Play()
Play1:Play()
wait(2)
db = true
elseif db == true then
--// Close Curtain
Play2:Play()
Play3:Play()
wait(2)
db = false
end
end)
Let me know if it helps!