The script under me dont work because delayTime will bugg the HingeConstraint:
robloxapp-20220806-0503067.wmv (3,7 MB)
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 or Position, both works" += train.CFrame.RightVector * ConvertToKMH(speed) * deltaTime
end)
So i made this but its not working:
runService.Heartbeat:Connect(function(deltaTime)
-- move the train forward "speed" KMH
train.CFrame.RightVector += (speed/3.57)*1000
end)
So the problem is, without delaytime the Train will run good but with it the other Parts who are connected with Hinge will run slower
Scottifly
(Scottifly)
August 8, 2022, 7:24pm
2
Why use a separate function to convert it?
Just make kilometersPerHour = studsPerSecond * 1.0084 in the bottom line and get rid of the function.
1 Like
Because somoene send me the script and why 1.0084?
Scottifly
(Scottifly)
August 8, 2022, 7:27pm
4
Look at the calculations in the function.
If you put in 1 stud/sec in you get 1.0084 km/h as an answer.
Scottifly
(Scottifly)
August 8, 2022, 7:35pm
6
Why? You have 2 conversions which means if you divide by 3.57, then multiply by 3.6 you get 1.0084.
It’s basic math.
Okay, like this?: train.CFrame.RightVector += speed * 1.0084
attempt to perform arithmetic (add) on Vector3 and number
It doesn’t take 3 braincells to understand the error.
You need to convert the right side of the equation into a Vector3, because as stated here RightVector is not infact a single integer.
Pegagittt
(Pegagit)
August 8, 2022, 8:26pm
10
With 3 Braincells u couldnt understand anything, i dont know what i should add after RightVector +=
I was gonna tell you but after treating me like that I don’t feel like it anymore.
hint: its Vector3.new(0,speed*1.0084,0)
or something along those lines
Pegagittt
(Pegagit)
August 8, 2022, 8:45pm
12
U said it first HAHA and thanks
Pegagittt
(Pegagit)
August 8, 2022, 9:01pm
13
Move the numbers around, for instance try Vector3.new(speed * 1.0084,0,0)
or Vector3.new(0,0,speed * 1.0084)
Pegagittt
(Pegagit)
August 8, 2022, 9:48pm
15
Yeah i did Vector3.new(0,0,speed * 1.0084) but its not working but this works:
local runService = game:GetService("RunService")
local train = script.Parent
runService.Heartbeat:Connect(function()
train.AssemblyLinearVelocity = script.Parent.CFrame.RightVector*-15
end)
But i dont need this why the other one dont work
Scottifly
(Scottifly)
August 9, 2022, 7:29pm
16
You mentioned Yeah i did Vector3.new(0,0,speed * 1.0084) but its not working
But as @TestyLike3 said, did you try putting the 1.0084 in the X position?
Pegagittt
(Pegagit)
August 9, 2022, 10:34pm
17
Yeah i did it, it worked, i copied the Train to a other Game and tried it there but i forgott that i dont have Collision Group there thats because it didnt worked but thanks
Scottifly
(Scottifly)
August 10, 2022, 12:09am
18
Please mark the post that solved your issue with the Solution button so other people won’t read it to try to solve it.
It also helps if someone searches for a post about the topic. Your post would come up in the search as Solved.
Pegagittt
(Pegagit)
August 10, 2022, 3:45am
19
I marked it to you already hours before just saw its unmarked
1 Like