How To Stop Vehicles From Moving

I’ve already searched through every topic with a similar title but none of them helped me. I’m using the default car from the racing template and I’m trying to stop movement but it isn’t working. I’ve tried setting MaxSpeed to 0 and Throttle to 0 but no luck yet. Can anyone help me?

Maybe try anchoring the car? char

Oh, I forgot to say I also tried that. It works but if I unanchor it and the player is holding W then they immediately go to their max speed, basically no acceleration time.

My idea may be janky but in my mind (uh oh) it should work. Basically, when you don’t want the vehicles features of moving (acceleration, brake, turn, etc.) available, you can have a second seat (regular seat, not a VehicleSeat), in the same position, orientation, and size as the VehicleSeat and just swap the Enabled property (which allows the player to sit down) of each seat when you want the player to be able to use it. Also, you’d want to set the players Humanoid.SeatPart property to the opposite seat.

For example, when the car should be able to move, the player would at first be sitting in the regular Seat. The VehicleSeat is then enabled, the player is moved to that seat, and the regular Seat is disabled.

1 Like

While you’re switching seats, wouldn’t it play the little animation that plays when you first sit down though?

Maybe you can elaborate on what you are trying to achieve when you say “no movement” because if you just dont touch any controls the car stops pretty quickly.

As in, if you click w or s (or touch forward or back) you won’t move the car, it’ll stay where it is.

1 Like

In the car’s script, just set this line back to true and the controls(movement) will be disabled:

localCarScript.Disabled = true

It is part of this code:

car.DriveSeat.Changed:connect(function(property)
	if property == "Occupant" then
		if car.DriveSeat.Occupant then
			car.EngineBlock.Running.Pitch = 1
			car.EngineBlock.Running:Play()
			local player = game.Players:GetPlayerFromCharacter(car.DriveSeat.Occupant.Parent)
			if player then
				car.DriveSeat:SetNetworkOwner(player)
				local localCarScript = script.LocalCarScript:Clone()
				localCarScript.Parent = player.PlayerGui
				localCarScript.Car.Value = car
				localCarScript.Disabled = false
			end
		else
			car.EngineBlock.Running:Stop()
		end
	end
end)

I did try that but that means that they can’t hold any keys before it gets re-enabled because it’s not listening for them. This is for a racing game and so it would be great if you could hold W before the race starts.

1 Like

Ok inside the CarScript go to LocalCarScript and find this part of the code:

while game:GetService("RunService").Heartbeat:wait() and car:FindFirstChild("DriveSeat") and character.Humanoid.SeatPart == car.DriveSeat do
		--game:GetService("RunService").RenderStepped:wait()
		if IsGrounded() then
			if movement.Y ~= 0 then
				local velocity = humanoidRootPart.CFrame.lookVector * movement.Y * stats.Speed.Value
				humanoidRootPart.Velocity = humanoidRootPart.Velocity:Lerp(velocity, 0.1)
				bodyVelocity.maxForce = Vector3.new(0, 0, 0)
			else
				bodyVelocity.maxForce = Vector3.new(mass / 2, mass / 4, mass / 2)
			end

Then change this line to the following:

humanoidRootPart.Velocity = humanoidRootPart.Velocity:Lerp(velocity, 0)

You are changing the 0.1 to 0.
It should now not move. To get it moving again script it to change back to 0.1.
Hope this helps!

Sorry for not replying to you straight away. This only slows down the vehicle but doesn’t stop it, unfortunately.

For me it makes it so that it doesnt move at all… this is the car in the race template correct?

Correct. At first it stays sort of still, but if you hold it for longer it starts to accelerate.

The only difference is that it gets cloned from Replicated Storage and the player is forced onto the seat.

Edit: I have found a solution: (For now)
Before line 14 I basically just copied everything inside of the Changed event:

if car.DriveSeat.Steer ~= 0 then
	movement = Vector2.new(car.DriveSeat.Steer, movement.Y)
end
if car.DriveSeat.Throttle ~= 0 then
	movement = Vector2.new(movement.X, car.DriveSeat.Throttle)
end

And if I disable the script and then re-enable it, it’ll work fine now.

1 Like

Never mind, this doesn’t work very well. Half the time it makes you unable to move at all and sometimes it’s lying on the floor like it’s resting. Do you have any other suggestions?

Did you make any other changes to the original script? I will try what i posted again because i wasnt able to replicate your issue with it moving again… works well for me.

Edit: i tried it off-road maybe thats why… i will try again on flat ground maybe it makes a difference.

You’re right, it slowly creeps forward. I will keep trying.

Thanks, sorry to bother you, it’s just that I keep trying but can’t figure out how to do it. You wouldn’t think it would be this hard…:sweat_smile:

Oh, yeah I think I forgot to mention that I’m only using the car, I didn’t keep the rest of the template, I’m just using a normal baseplate.

1 Like

For anyone else who needs a solution for this, I found that welding the vehicle seat using a weld constraint to any anchored part works.

This was the first thing I tried, but in my testing i would fling from the seat when it got anchored… and also when I unanchored as well.