A-Chassis Tune Cruise Control

I’m using A-Chassis Tune 6.52S2 and trying to create a cruise control plugin. Here’s what I have so far, but it doesn’t work.

local cc = false
local p = game.Players.LocalPlayer
local m = p:GetMouse()
local targetspeed = 0
local car = script.Parent.Car.Value

m.KeyDown:Connect(function(key)
	if key == "r" then
		if cc == true then
			print("CC Off")
			cc = false
		else
			print("CC On")
			cc = true
			targetspeed = math.floor(car.DriveSeat.Velocity.Magnitude)
			repeat
				if car.DriveSeat.Velocity.Magnitude > targetspeed then
					script.Parent.Values.Throttle.Value = 0
					car.SetThrottle:FireServer(0)
				else
					print(targetspeed - car.DriveSeat.Velocity.Magnitude)
					script.Parent.Values.Throttle.Value = math.min(((targetspeed - car.DriveSeat.Velocity.Magnitude) / 10) + (1 * 2), 0.75)
					car.SetThrottle:FireServer(math.min(((targetspeed - car.DriveSeat.Velocity.Magnitude) / 10) + (1 * 2), 0.75))
				end
				wait(1)
			until cc == false
		end
	end
end)
2 Likes