Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make my train go around tracks smoothly?

Hi, so I have my train which works, but it looks weird when its moving. It has a pause in between the nodes and it doesn't go very smooth.

Video: https://streamable.com/1wbhua

My Code:

local RunService = game:GetService("RunService")

local node = 0

function movemodel(model,start,End,AddBy)
    for i = 0, 0.5, 0.01 do
        if not model.PrimaryPart then break end
        model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame:lerp(start.CFrame, i))
	RunService.Heartbeat:Wait()
    end
end

while true do
	local nextnode = game.Workspace.Nodes:FindFirstChild(node + 1)
	local End = game.Workspace.Nodes:FindFirstChild(node + 2)
	node = node + 1
	movemodel(script.Parent,nextnode,End)
end

5 comments

0

This is a hard thing to pull off . for exemple jailbreak managed to pull it off in 2018 wich is insane

0

I already did it, i just wanna know how to slow down the lerps

0

I don't have any specific code, but on twitter, I saw Egomoose post an example and say he was using timing sequences of some sort.

0

Send me the tweet link pls

0

You should use tween service for the train, its more what your looking for

1 answer

What happens when you take out the Wait?

Try removing this line:

 RunService.Heartbeat:Wait()

But in removing the wait, it probably will go too fast...

To get smooth motion, at a reasonable speed, I think the use of align constraints and physics may be the way to go, instead of cframing..... I saw an example on the dev forum that I'll try to find for you, today.

1 comment

0

It just goes straight to the end if i remove it

This discussion is preserved as it was. New answers, comments, and votes are closed.