#Doors opening moves the whole train to the other line

1 messages · Page 1 of 1 (latest)

severe sable
#

@vernal ridge @quasi grove

#

why is it happening again

#

works fine with this one

coral mason
severe sable
severe sable
# coral mason
function OpenDoorMovement(doors)
    
    local TranslationPart = nil
    
    for _, door in pairs(doors) do
        TranslationPart = door.parent.parent.parent.Translation
        for _, doorModel in pairs(door:GetChildren()) do
            for _, doorPart in pairs(doorModel:GetChildren()) do
                doorPart.CanCollide = false
                local doorsoundopen = Instance.new("Sound")
                doorsoundopen.SoundId = "rbxassetid://18121742113"
                doorsoundopen.Volume = 0.0025
                doorsoundopen.Parent = doorPart
                doorsoundopen:Play()
            end
        end
    end
    
    wait(2)
    print("opening doors")

    for _, Weld in ipairs(TranslationPart:GetChildren()) do
        if (Weld:IsA("Weld") and Weld.Part1.Parent and Weld.Part1.Parent.Name:find("Door ")) then
            table.insert(CachedWelds, Weld);

            Weld.Enabled = false;
            Weld.Part1.Anchored = true;
        end
    end


    for z = 0, 5, 0.2 do
        for _, door in pairs(doors) do
            if (door.Name == "Doors RA") or (door.Name == "Doors LA") then
                door:PivotTo(door:GetPivot() * CFrame.new(-0.1, 0, 0))

            else
                door:PivotTo(door:GetPivot() * CFrame.new(0.1, 0, 0))

            end
        end
        wait()
    end
end```
quasi grove
#

It looks like you still move things if the name of the part isn't one of the doors

severe sable
quasi grove
severe sable
#

I can fix that if you want

#

But it will have the same outcome

quasi grove
#

So this is the client doing something different than the server again?

severe sable
#

this is the train moving funcky

#

something to do with welds i think

quasi grove
quasi grove
# severe sable

I think it's the fact you're moving the part. If it's still welded, its gonna move the thing its attached to

gray ravenBOT
#

studio** You are now Level 6! **studio

quasi grove
#

Is that train setup like the other one? If it works for one, but not the other, find out in what way they differ

severe sable
#

Yes

#

They literally don’t

#

I don’t get it

quasi grove
# severe sable Ges

Are the welds parented the same?

Like is Part1 always the door for both trains? (not the specific door, but like, is Part1 always a door)

severe sable
#

They are always named the same

quasi grove
#

Something's up, because the doors aren't moving and you're moving the whole train instead.

You gotta print out what you're moving when you move it to ensure it's what you think.

It looks like you're pivoting the entire train rather than a single door.

severe sable
#

because if i get it to turn around a track

#

the doors open inside itself

quasi grove
# severe sable the doors open inside itself

Well when you do door.CFrame * CFrame.new(-1, 0, 0), that is going to be one unit to the door's left. So you have to make sure you're doing something similar.

A demo would help, and a code snippet of where you're moving the doors

severe sable
#

well video

#
function OpenDoorMovement(doors)
    
    local TranslationPart = nil
    
    for _, door in pairs(doors) do
        TranslationPart = door.parent.parent.parent.Translation
        for _, doorModel in pairs(door:GetChildren()) do
            for _, doorPart in pairs(doorModel:GetChildren()) do
                doorPart.CanCollide = false
                local doorsoundopen = Instance.new("Sound")
                doorsoundopen.SoundId = "rbxassetid://18121742113"
                doorsoundopen.Volume = 0.0025
                doorsoundopen.Parent = doorPart
                doorsoundopen:Play()
            end
        end
    end
    
    wait(2)
    print("opening doors")

    for _, Weld in ipairs(TranslationPart:GetChildren()) do
        if (Weld:IsA("Weld") and Weld.Part1.Parent and Weld.Part1.Parent.Name:find("Door ")) then
            table.insert(CachedWelds, Weld);

            Weld.Enabled = false;
            Weld.Part1.Anchored = true;
        end
    end


    for z = 0, 5, 0.2 do
        for _, door in pairs(doors) do
            if (door.Name == "Doors RA") or (door.Name == "Doors LA") then
                door:PivotTo(door:GetPivot() * CFrame.new(-0.1, 0, 0))

            elseif (door.Name == "Doors RB") or (door.Name == "Doors LB") then
                door:PivotTo(door:GetPivot() * CFrame.new(0.1, 0, 0))
                
            else
                print("something check which shouldnt have: ", door.Name)
            end
        end
        wait()
    end
end```
#

so this is where I open the door, now of course i understnad that because the CFrame value is fixed when the train moves it will be wrong but how do i understand that and fix that in the code

quasi grove
severe sable
quasi grove
quasi grove
# severe sable

Okay well I didn't mean literally just that, I meant like instead of using door:GetPivot you'd use door.CFrame

severe sable
#

but that doesnt make sense because it opens the doors fine

#

oh wait

#

okay i fixed that

#

let me see if it works

#

no work

#

@quasi grove

quasi grove
severe sable
#

and before it was fine

#

so this is where it spawns

severe sable
#

wait

#

okay @quasi grove ignore that

#

this is the error

severe sable
quasi grove
# severe sable

Right, do .PrimaryPart.CFrame instead of just .CFrame, I didn't realize the doors were models

#

if you have the PrimaryParts of the doors set...

severe sable
#

what does primary part do?

quasi grove
#

I mean the :GetPivot may work if you set the PrimaryPart

I'm not 100% I'm guiding you in the right direction tbh

severe sable
quasi grove
severe sable
#

look we have 2 stations

quasi grove
severe sable
#

how could i get it so that both stati on swork

#

as with the pivot one require z and one require x

quasi grove
severe sable
#

one sec let me vid it

#

just incase you dont understand right

quasi grove
severe sable
#

so its one long track

#

the train moves on it

#

so if we change the x to y then the first station has the issue that the first station does

quasi grove
#

At first station then second

severe sable
#

this will do right

quasi grove
severe sable
#

oh right

#

so the same

quasi grove
quasi grove
severe sable
quasi grove
severe sable
#

so broke

quasi grove
severe sable
#

second station the same

#

so thats good right

quasi grove
severe sable
#

they both work now