Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i increase the speed of an automatic train?

Asked by 6 years ago

I have a train made by someone else and its so slow i want to make it fast how do i do it

2 answers

Log in to vote
0
Answered by 6 years ago

Depends. If it has an integrated script, then look through it and make sure it sets the speed to the desired value. Else, just look in the VehicleSeat part, and there should be its Properties. Then look at MaxSpeed. Torque is the value for how fast it will get to its MaxSpeed. Finally, Throttle is set to 1 so it knows to move forward, -1 backwards, or 0 to stop.

Ad
Log in to vote
0
Answered by 6 years ago

My scipt for the train is

local seat = script.Parent local carriage = seat.Parent local dl = carriage.DL:GetChildren() local dr = carriage.DR:GetChildren() local engine = carriage.Engine local engineBV = engine.BodyVelocity local panels = carriage.Destination:GetChildren()

local lastStation = nil local dir = seat.Throttle

function SetDirection(_Dir) if (_Dir == 0) then return end dir = _Dir for i,v in pairs(carriage.Lights:GetChildren()) do
if (v.Name == "A") then v.SpotLight.Color = (dir > 0) and Color3.new(1, 0.95, 0.88) or Color3.new(0.66, 0, 0) v.SurfaceGui.White.ImageColor3 = (dir > 0) and Color3.new(1, 0.95, 0.88) or Color3.new(0.1, 0.1, 0.1) v.SurfaceGui.Red.ImageColor3 = (dir < 0) and Color3.new(0.66, 0, 0) or Color3.new(0.1, 0, 0) else v.SpotLight.Color = (dir < 0) and Color3.new(1, 0.95, 0.88) or Color3.new(0.66, 0, 0) v.SurfaceGui.White.ImageColor3 = (dir < 0) and Color3.new(1, 0.95, 0.88) or Color3.new(0.1, 0.1, 0.1) v.SurfaceGui.Red.ImageColor3 = (dir > 0) and Color3.new(0.66, 0, 0) or Color3.new(0.1, 0, 0)
end end end

seat.Touched:connect(function(child) if (child.Name == "StationSensor") and (child ~= lastStation) then lastStation = child engine.Brake:Play() --print("Train stopped") seat.Throttle = 0 SetDirection(child.DepartDirection.Value) for i,v in pairs(panels) do if (child.SetName.Value ~= "") then v.SGUI.LineName.T.Text = child.SetName.Value end if (child.SetLine.Value ~= "") then v.SGUI.LineLine.T.Text = child.SetLine.Value end end local doors = child.DoorLeft.Value and dl or dr for i,v in pairs(doors) do v.CanCollide = false v.Transparency = 1 end wait(10) for i,v in pairs(doors) do v.CanCollide = true v.Transparency = 0 end seat.Throttle = dir end end)

SetDirection(dir)

engine.Clattering:Play()

while wait(0.1) do engineBV.velocity = engine.CFrame.lookVector * seat.Throttle * seat.MaxSpeed engine.Clattering.Volume = engine.Velocity.Magnitude / seat.MaxSpeed end

0
Please edit this and use the code block to get an easier view at this code. kakikito123 4 — 6y
0
From what I understood in this script, the MaxSpeed of the train doesn't seem to be getting affected by anything in this code. Your problem seems to be coming form the part itself having the MaxSpeed to a value you're not content with, try the Part's Properties again. This script just seems to work on making the train go, stop, playing the sounds and such, but not controlling its velocity. kakikito123 4 — 6y

Answer this question