How to use CFrame to move a Parent, and all it's Children as well.


  • Hey, I'm making a door, and I can move the parent object, but I can't figure out how to move the parts inside the parent without having hundreds of lines of code. This is my code, (Other code is before this, but this is just for the door)

    local Debounce = false
    function openDoor()
    if not Debounce then
    Debounce = true
    if Open then
    Open = false
    CloseSound:Play()
    Spawn(function()
    for i = 1, 50 do
    LeftDoor.CFrame = LeftDoor.CFrame + (LeftDoor.CFrame.lookVector * 0.1)
    wait(0.05)
    end
    end)
    Spawn(function()
    for i = 1, 50 do
    RightDoor.CFrame = RightDoor.CFrame + (RightDoor.CFrame.lookVector * 0.1)
    wait(0.05)
    end
    end)
    else
    Open = true
    OpenSound:Play()
    Spawn(function()
    for i = 1, 50 do
    LeftDoor.CFrame = LeftDoor.CFrame - (LeftDoor.CFrame.lookVector * 0.1)
    wait(0.05)
    end
    end)
    Spawn(function()
    for i = 1, 50 do
    RightDoor.CFrame = RightDoor.CFrame - (RightDoor.CFrame.lookVector * 0.1)
    wait(0.05)
    end
    end)
    end
    wait(2.5)
    Debounce = false
    end
    end



  • Oh, I'm sorry

Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.