How to make a working animated roller coaster

Hello there :slight_smile:
I’m Woodx, and I’ve made alots of tutorials, and if you like my tutorials, please donate by paypal or by robux,anyways lets begin the tutorial

If you have read my other basic train tutorial: How to make a basic train
It actually de-rails, like an original train, its based on Roblox physics, but many of the developers messaged me saying, how they can make a animated train, in simple

In this tutorial, you will learn how to make a moving roller coaster/ train

In the video, you actually see, the roller coaster moves, at a speed, to the track, however, you can also add carts like

  • 3 carts roller coaster
  • 4 carts roller coaster
  • 10 carts roller coaster

However, I cannot tell you surely, 10 carts moving will be good performance, if your looking for something like in Theme park tycoon, its probably 10 moving LPM (Low Poly Meshes), its like 10 parts moving, so it would be great, but for some developer like me, who makes every thing inside roblox, you have to go for fewer carts

Step 1: Making tracks and track folder

image
First add a folder, in workspace
Name it anything you wish, I will name it “TrackFolder” to make the tutorial simple and easy to understand

Add a part to it, which is your track, you can name it “1” or just don’t rename it, its good if your re-naming, because, the roller coaster will move from 1- (your number of tracks), but if you don’t name it, it just takes the order of parts

I will tell you how to make a moving coaster from both the methods of track

  • Name like 1,2,3,4,5
  • Order of tracks

Now, make your track, you can either use a union( a single part) or a mesh, for the sake of difficulty, don’t go for models, it will make the word, hard but its still possible

Step 2: Making tracks


Make one track, any track, it does not matter, I made this simple ,uh some kinda track

Ez

Uh, now name it thats all, if you don’t wanna name them, skip this part
image

Step 3: Making tracks to form a huge map

Get this plugin to make it easier to make tracks


Make your track, and then name it
image
1,2,3,4

I know its hard, if you don’t want to do this, then you should clone your tracks in order, like you have to
clone a track, and make sure its below the first track, this will make it easier

Step 4: Making the roller coaster

Now, to avoid train going sideways, like train going left or right, or in simple words, in the wrong way
Make sure your track and coaster are of same sides

Like, let me explain
Add a surface selection, and set the adornee to the track, and see which side of the track is front side
image

Backside of the track, is front
As you see the backside of track is front

Like that, find what is your side of the track, now make sure the same side of the roller coaster base is also like that, I will show what it means in this image

Like if backside of the track is front for the train, then make sure your roller coaster backside also faces front
image
In this image, the blue highlighted, is backside, and as you see both backsides of track and roller coaster are same, hope you understood, read this section again, if you did not understand, its simple trust me

Step 5: Making script

If your a new scripter, or you find scripting hard, you shouldn’t have to worry, this is a 10 line script max, yes it is 10 line max
Also if you used track number system, you should do this:

local ts = game:GetService("TweenService")

for i = 1,8 do -- a fininite loop, in maths, we call it summation, or sigma notation
    local info = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0) -- info, you can edit, this but, you should also edit the wait function below to make train move correctly
    local goals = {
        CFrame = game.Workspace.TrackFolder:FindFirstChild(i).CFrame + game.Workspace.TrackFolder:FindFirstChild(i).CFrame.UpVector*2
    }
    local part = script.Parent -- the part which is going to tween
    local anim = ts:Create(part,info,goals)
    anim:Play() -- this will play the animation, tween animation, it will tween the train
    task.wait(0.3) -- waits 0.3, not 0.5 because, after 0.2 the train will stop, so before the train stops, we make it move, to avoid random speed, like slow then fast,then slow, then fast
end

If your going for order of tracks, go for this:

for i,v in pairs(game.Workspace.TrackFolder:GetChildren()) do
    local info = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
    local goals = {
        CFrame = v.CFrame + v.CFrame.UpVector*2
    }
    local part = script.Parent
    local anim = ts:Create(part,info,goals)
    anim:Play()
    task.wait(0.3)
end

You can see the script and read it carefully, you can actually see how it works if you understood it
Test it, I see it moving, sorry but my recorder broke, and I’m unable to show the video, but you can actually notice, your train moves, but if your train/roller coaster is moving to random tracks, it means your track is wrongly re-named, or wrong order, so you should go for number system if wrongly ordered tracks, and if your train is going to random tracks, then you should check if you named your track correctly

Note: this is how you actually do it


You don’t have to name, your first track, like the starting of track anything, because, the train, won’t go to it, unless, you make a loop, like a track going to start

Also, you can also make a physics thing, like if your roller coaster is going upwards, it goes slow, however its too hard for normal devs, (I also don’t know how to do it clearly to tell it lol)

Step 6 Done

Now, you need to weld your roller coaster, parts to the train, to make one good looking train, but make sure the parts welded to the train/roller coaster are unanchored, only the train part should be anchored

Thats it, tutorial is done, enjoy, please donate if you wanna thank me, it took me 2 hours to write this tutorial

References

Support me

Paypal

44 Likes

It’s Archimedes v3? use track with archimedes?

5 Likes

Yes its Archimedes V3

1 Like

Dude this is one of the best tutorials

2 Likes

Hate to bump but, I have gotten the error “attempt to index nil with ‘CFrame’”, line 6
On the script here:

local ts = game:GetService("TweenService")

for i = 1,8 do -- a fininite loop, in maths, we call it summation, or sigma notation
	local info = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0) -- info, you can edit, this but, you should also edit the wait function below to make train move correctly
	local goals = {
		CFrame = game.Workspace.TrackFolder:FindFirstChild(i).CFrame + game.Workspace.TrackFolder:FindFirstChild(i).CFrame.UpVector*2
	}
	local part = script.Parent -- the part which is going to tween
	local anim = ts:Create(part,info,goals)
	anim:Play() -- this will play the animation, tween animation, it will tween the train
	task.wait(0.3) -- waits 0.3, not 0.5 because, after 0.2 the train will stop, so before the train stops, we make it move, to avoid random speed, like slow then fast,then slow, then fast
end

Were we supposed to weld it? Anchor it? I am confused.

You should make a folder or it will return an error ofc

It is in a folder. Named exactly as above. It it just saying “Attempt index nil with CFrame”.

1 Like

Oh it means there is an error find the part, did u name it as 1 2 3 4 5?

image
This is currently how I have it laid out.

Uh show me your script? So I can see why was there an error?

local ts = game:GetService("TweenService")

for i = 1,8 do -- a fininite loop, in maths, we call it summation, or sigma notation
	local info = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0) -- info, you can edit, this but, you should also edit the wait function below to make train move correctly
	local goals = {
		CFrame = game.Workspace.TrackFolder:FindFirstChild(i).CFrame + game.Workspace.TrackFolder:FindFirstChild(i).CFrame.UpVector*2
	}
	local part = script.Parent -- the part which is going to tween
	local anim = ts:Create(part,info,goals)
	anim:Play() -- this will play the animation, tween animation, it will tween the train
	task.wait(0.3) -- waits 0.3, not 0.5 because, after 0.2 the train will stop, so before the train stops, we make it move, to avoid random speed, like slow then fast,then slow, then fast
end
1 Like

You have 3 parts, now in the code it is a for loop 1 to 8, change it to for i = 1,3.

I don’t get why the tutorial does not use a for i, v in instead.

Alright, Thanks. It works alright now.

1 Like

Do you have a studio download for this example?

1 Like

No sir, I can make it for you if you really want it?

How do I link my cars? I am planning to make multiple cars that attaches to the main part of the train. Do I use HingeConstraints?

1 Like

Yes

Sorry for bump
But yes please. I think a roblox studio download would be usefull.
i cant get more then 1 cart working

1 Like

Sure, I would do that soon for you. Until then, here is a workaround: You can tween one cart by one cart, starting from first cart, and then a delay of few seconds (according to the speed of the cart) and then same tween for the 2nd cart. But at last, the first cart will stop a bit front, and last cart will stop a bit back. That means you end the tweens of first cart when it reaches the most distance but u end the last cart tween earlier

Sorry for a pretty late reply, I really didn’t saw it before.

The thing is, if you mistakenly deleted one part and then you added it back, the position of it goes to 1, so your coaster randomly goes to random tracks, making it look very bad and not like a roller coaster.

I’m making an upgraded tutorial on how to make a drivable train based along with tracks, you can replicate it to make a roller coaster, and you can also remove the driving functionality, and the movement of the coaster is forward/backward, so you don’t need to name it, or use i,v loop