How to make train doors

Problem: i don’t know how to make train doors

tried sollution: tweenservice

the doors are welded to the train and exist out of two unions. the doors can be opened by a button and the driver can lock the doors by disabling the script.

Are you using a ProximityPrompt or just a ClickDetector?

clickdetector is what i use. i dont think proximity is good for that.

Why not doing tweenservice? If you want to lock them, you could do:

local locked = false

ClickDetector.MouseClick:Connect(function()
	if locked == false then
		-- tweens here
	end
end)
1 Like

but how do i need to make the doors stay by the train, because if i weld them, it doesn’t work

You could weld them to a train, but when the train stops, anchor the doors and unweld them, and then do the tweens. That’s my only idea.

i guess i can try that
i’ll be back in a moment

I would use PrismaticConstraint for this situation:
https://developer.roblox.com/en-us/api-reference/class/PrismaticConstraint
image

According to API wiki about the ActuatorType of PrismaticConstraint:

Which means you can create sliding door with PrismaticConstraint.

You can follow this steps for making a basic train door:

  • Make a part and set the name to DoorBase.

  • Next, pick your door and make PrismaticConstraint between DoorBase and your train door (thin block is DoorBase) :
    image

  • After that, set the PrismaticConstraint's ActuatorType to Servo:
    image

  • Then, increase the ServoMaxForce value to really high, set the Speed value to 2.

  • Finally, weld the DoorBase to your trains body.

Now you’re created a sliding train door! Now try to change TargetPosition value of PrismaticConstraint in test mode.

(Be sure your train door isn’t anchored or welded otherwise it will not work.)

3 Likes