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

How do i increase the speed of an automatic train?

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

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.

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

2 comments

0

Please edit this and use the code block to get an easier view at this code.

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.

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