I am working for a special game for my friend and I have already built my custom train, included some sliding doors, and when I wanted to make the train move once I entered inside I included this:
local Train = script.Parent
local function onTouch()
for i = 0,1,.001 do
Train:SetPrimaryPartCFrame(Train:GetPrimaryPartCFrame() * CFrame.new(0,0,i))
wait()
end
end
script.Parent.Touched:connect(onTouch)
I placed this script in a part inside said Model(Train). The part is located directly in the middle of the train, so when I pass the sliding doors I immediately touch said part to make the train move, yet the train doesn't move when I touch it. I also placed a part above the train, naming it MainPart and making said MainPart into a primary part for my train. Can someone help me in on this? I am still a beginner at scripting.

5 comments
Still didn't make my train move.
Were the trains never moving to begin with? I normally weld my stuff and use a body velocity for the movement
I didn't weld anything, I just anchored the entire train after I finished building it
And yes, the train was never moving to begin with. It's just there. I just wish for the player to get transported to another spot once they hop inside.
Alright, I'll try and weld the parts and then use body velocity for the movement.