Sorry for not mentioning earlier but is it possible that you can rename each track section with its corresponding number? It would help with performance because instead of checking the distance every frame it could just check if the number is correct.
Put this inside of StarterPlayerScripts and see if it works:
--//Services
local TweenService = game:GetService("TweenService")
--//Variables
local Cart = workspace.Cart --//Whatever it's called
local TrackSections = workspace.TrackSections --//Whatever it's called
--//Functions
for i = 1, #TrackSections:GetChildren() do
local trackSection = TrackSections:WaitForChild(i)
local cartTween = TweenService:Create(Cart.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Linear), {
CFrame = trackSection.Metal.CFrame + Vector3.yAxis * 5
})
cartTween:Play()
cartTween.Completed:Wait()
end
You will need to tweak some things but we can go over that after you can test it.
ALSO, only change the name of the tracks if you want to, if there are even just 50 tracks it will be a pain to name them all so you don’t have to, just make sure to tell me what you choose to do though.
I would advise against tween service for this. TweenService is specifically designed to ignore physics limitations. While it’s smooth, this is pretty bad for cart-ride games. Relying on vehicle physics instead is much better.
free hinges connecting the axles to the body to let the axles rotate to match the track’s rotation
motorised hinges connecting the wheels to the axles to let the cart move forwards and backwards
[optional] spring constraints for damping and cool smooth cart rides that aren’t rigid. Take a look at “cart ride around nothing” for inspiration for this one.