I would like to make this system to accelerate and deaccelerate at a normal rate!
The issue is that this system is increasing the speed drastically every time I press W and after a short bit it will stop. Any help would be great!
Code:
local seat = game.Players.LocalPlayer.Character.Humanoid.SeatPart
local vel = game.Players.LocalPlayer.Character.Humanoid.SeatPart.Parent.Base.BodyVelocity
local Velocity = script.Velocity
seat.Changed:connect(function(type)
if type == "Throttle" then
local Input = seat.Throttle
repeat
Velocity.Value = Velocity.Value + Input
if Input*Velocity.Value/math.abs(Velocity.Value) == -1 then
wait(1/script.Deceleration.Value)
else
wait(1/script.Acceleration.Value)
end
if Velocity.Value > script.MaxSpeed.Value then
Velocity.Value = script.MaxSpeed.Value
elseif Velocity.Value < 0 then
Velocity.Value = 0
end
until seat.Throttle ~= Input
end
end)
while script.Parent ~= nil do
wait()
vectorpower = script.MaxPower.Value*seat.CFrame.lookVector
vel.MaxForce = Vector3.new(vectorpower.X>0 and vectorpower.X or -vectorpower.X,
vectorpower.Y> 0 and vectorpower.Y or -vectorpower.Y,
vectorpower.Z> 0 and vectorpower.Z or -vectorpower.Z
)
vel.Velocity = Velocity.Value*seat.CFrame.lookVector
end
I have been looking around but can’t seem to find a solution. all help given would be great!
You can see what I mean here: Test Track - Roblox