About
Hello, I am currently trying to create an automatic train for a subway game I work on together with others. I have built and scripted the train. I used PrismaticConstraints, set on Servo, to move the train along the rail by self. I also tried to achieve a smooth deceleration by this way.
repeat
script.Parent.PrismaticConstraint.Speed = script.Parent.PrismaticConstraint.Speed - 0.4
wait (0.001) -- Decrease speed by 0.4 every 0.001 seconds, until a speed less than 1 is achieved
until script.Parent.PrismaticConstraint.Speed < 1
script.Parent.PrismaticConstraint.Speed = 0 -- Fully stops the train.
The issue
My scripting is rather unconventional, as I am not really experienced in scripting.
When the train is driving, it will touch a brick on the track, firing an event to run these lines above. When I tested the train multiple times, with different computers on different graphic settings, the train always stopped at a different point, so I now am concerned that too many players, or players using lower tier computers could cause the train not stopping at the right point, so it decelerates at different speeds, causing the train to not stop at the right point.
Link to Game
Here is the link where you can test that place. The train should be behind you and leave the station after around a half minute. If you want to test it multiple times, you have to join a new game.