robloxapp-20220806-0503067.wmv (3,7 MB)
The other Parts of the Train is just following slowly the Front Part.
local runService = game:GetService("RunService")
local train = script.Parent
local speed = -80
local function ConvertToKMH(studsPerSecond)
local metersPerSecond = studsPerSecond / 3.57
local kilometersPerHour = metersPerSecond * 3.6
return kilometersPerHour
end
runService.Heartbeat:Connect(function(deltaTime)
-- move the train forward "speed" KMH
train.position += train.CFrame.LookVector * ConvertToSPS(speed) * deltaTime
end)
RMofSBI
(RMofSBI)
#2
In the video your train is moving, what is the issue?
The Middle and Back Part of the Train are slowly moving with the front part of the Train who is connected with a Hinge
RMofSBI
(RMofSBI)
#4
And the issue is what? That its too slow?
The Train parts are too far away
RMofSBI
(RMofSBI)
#6
Oh I see now… the train is stretching.
A hinge won’t do this but rope constraint will and if you want to reduce the stretch of the rope then lower its Restitution closer to zero.
This works:
while task.wait() do
script.Parent.AssemblyLinearVelocity = script.Parent.CFrame.RightVector*-15
end
But this not:
(I need this because i want to convert it into KMH)
local runService = game:GetService("RunService")
local train = script.Parent
local speed = -80
local function ConvertToKMH(studsPerSecond)
local metersPerSecond = studsPerSecond / 3.57
local kilometersPerHour = metersPerSecond * 3.6
return kilometersPerHour
end
runService.Heartbeat:Connect(function(deltaTime)
-- move the train forward "speed" KMH
train.CFrame += train.CFrame.LookVector * ConvertToKMH(speed) * deltaTime
end)
RMofSBI
(RMofSBI)
#9
Does it show errors in output?
Im not that fluent in script but im sure the issue is with how you are applying the deltatime.
There isnt much literature on it, sorry i cant help further.
No it dont but okay thanks
1 Like