My drive-able monorail won't work

Hello all.

I am making a drive-able monorail and it won’t work. It works fine until I get into it and drive it. Then it just stops and doesn’t let me drive it.
Monorail pic:
Processing: Screen Shot 2022-10-09 at 3.27.57 PM.png…
Script 1:

local Seat = workspace.Monorail.VehicleSeat

Seat.MaxSpeed = 150
Seat.Torque = 50

Seat:GetPropertyChangedSignal("Throttle"):Connect(function()
	game.ServerStorage.Value.Value *= Seat.Throttle
end)

Script 2:

game["Run Service"].Heartbeat:Connect(function()
	workspace.Monorail.Base.AssemblyLinearVelocity = Vector3.new(game.ServerStorage.Value.Value,0,0)
end)

There’s a numbervalue set to 15 in serverstorage.
No errors in the output.
Thanks @Tomroblox54321

1 Like

Could you make a video of your problem?

Sorry it took so long and thanks.
@Katrist

Are you holding W when you get in the monorail?

I am holding w/forward arrow(character limit).

The problem is that the throttle property of the VehicleSeat resets to 0 upon first entering it, thus setting the value in ServerStorage to 0 (15 * 0 = 0). In your first script, you could set its value without referencing the old one, like this:

game.ServerStorage.Value.Value = 15 * Seat.Throttle

I see, but when I am pressing w wouldn’t the throttle go up which would change it to be (15 * .1 = 1.5).

I believe you’re overlooking the fact that the value will no longer be 15 at that point, but 0. It can never recover from that since anything times 0 will still equal 0.

He isn’t setting the throttle manually so this isn’t the problem.

Well, this isn’t about the throttle property of the seat, but about the value object he’s using. Look at the following line in the first script he provided:

game.ServerStorage.Value.Value *= Seat.Throttle

With some reformatting, it will look like this:

game.ServerStorage.Value.Value = game.ServerStorage.Value.Value * Seat.Throttle

Now, initially setting Value.Value to 0 will result in all future values being 0.

I take it that you’re using a value object in order to easily modify the monorail’s maximum velocity. A good way of utilizing the functionality of said object would be to initially read its value and save it as a variable somewhere in your code.

I modified the first script to look like this:

local Seat = workspace.Monorail.VehicleSeat
local MaxVelocity = game.ServerStorage.Value.Value

Seat.MaxSpeed = 150
Seat.Torque = 50

Seat:GetPropertyChangedSignal("Throttle"):Connect(function()
	game.ServerStorage.Value.Value = MaxVelocity * Seat.Throttle
end)

Oh that is true, sorry for not getting it at first.

Solved! Thank you so much @Tix1511 and @Katrist for helping.