#Doors opening moves the whole train to the other line
1 messages · Page 1 of 1 (latest)
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```
It looks like you still move things if the name of the part isn't one of the doors
well it doesnt matter because there are only 4 modles im moving
Well if the door's name is "Doors RA" or "Doors LA", it'll move it to the left
if not, it'll move whatever that is to the right
Yes but it’s moving whatever is in the tree
I can fix that if you want
But it will have the same outcome
So this is the client doing something different than the server again?
no
this is the train moving funcky
something to do with welds i think
I guess it'd depend on what you're changing about the weld to open it. Can you just show me that little bit of code?
I think it's the fact you're moving the part. If it's still welded, its gonna move the thing its attached to
But I unweled it
** You are now Level 6! **
Is that train setup like the other one? If it works for one, but not the other, find out in what way they differ
Ges
Yes
They literally don’t
I don’t get it
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)
Yes
They are always named the same
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.
okay so i fixed that issue now thank you but how could i open the train doors the same way each time?
because if i get it to turn around a track
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
yes one sec im getting the ss
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
Does this happen all the time? or do the doors open normally when the train is rotated the right way
no works fine when the train is the correct way
I wonder if the Pivot is always a zero orientation. Did you try door.CFrame * CFrame.new(0.1, 0, 0)?
Okay well I didn't mean literally just that, I meant like instead of using door:GetPivot you'd use door.CFrame
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
Okay, so that's a little different. Try the z-axis instead of the x-axis
no now this station broke
and before it was fine
so this is where it spawns
then the next station is the one which turns it
wait
okay @quasi grove ignore that
this is the error
this was the same code as before so ignore that
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...
i dont think i do
what does primary part do?
https://create.roblox.com/docs/reference/engine/classes/Model#PrimaryPart
It's where the pivot of the model is based off
I mean the :GetPivot may work if you set the PrimaryPart
I'm not 100% I'm guiding you in the right direction tbh
so i set primary part to the model that groups them all?
No just the door model to whatever the "base" should be within the door model.
Maybe I'm just going a bit too far. We may want to revert back to just using the Pivot. Maybe if you go back and use the Z-axis instead of the X-axis with your original code, that might work.
yes but then the orignal station wont work
look we have 2 stations
Yes but I worry I'm going too far and want to go back to the start so I don't make you do tons of changes that don't matter.
so if we use pivots
how could i get it so that both stati on swork
as with the pivot one require z and one require x
Let's check both doors. It could be possible that both door models are rotated, causing this issue, so not code.
wait check this
one sec let me vid it
just incase you dont understand right
It works for one station but not the other, I get that
Is it the same exact train and doors?
yes
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
Can you print door:GetPivot():ToEulerAnglesXYZ() just before you change the door's CFrame? I want to know what those values are
At first station then second
Well you have to print it, so wrap it with a print()
That confirms my suspicion.
The door's pivot is not changing, so -1 on the X axis is always the same.
so how can i fix this?
Try setting the PrimaryPart of every door model to some part on that door. (no code) and see what that changes
doesnt matter what part of the door?
Whatever you feel is best
first station it moves liek second station
so broke
but second station...?
Awesome, try another axis
first station door's are now working
they both work now