So I made a hopperbin, that will control a basic ship, I'm taking it easy and it only moves on the Z axis but, when 'W' is pressed, then released, the velocity keeps increasing. I know that a lot of this code is inefficient and messy, but I'm a beginner.
tool = script.Parent player = tool.Parent.Parent.Character playerc = player:getChildren() for _,v in pairs(playerc) do if v:IsA("Part") then v.Touched:connect(function(hit) if hit:IsA("Seat")then ship = hit.Parent.ship function onKeyDown(key) if key == "W" or key == "w" or string.byte(key) == 113 or string.byte(key) == 87 then f = true debounce = false while f and wait() and not debounce do ship.BodyVelocity.velocity = ship.BodyVelocity.velocity + Vector3.new(10,0,0) end end end function onSelected(mouse) mouse.KeyDown:connect(onKeyDown) end tool.Selected:connect(onSelected) end end) end end
Your ship is accelerating forever because you did not include code to slow it down! Example code to slow:
if key == "s" or key == "S" then f = true debounce = false while f and wait() and not debounce do ship.BodyVelocity.velocity = ship.BodyVelocity.velocity - Vector3.new(10,0,0)