So I'm currently trying to make a fly script, whenever someone presses a letter they will (automatically) go up, instead of a slow levitation. But I want to know how can I stop BodyVelocity from floating me up? Is there a way that I can make it where my character just goes up in the air, doesn't move. Whenever a key is pressed W A S D Space and CTRL they will change positions and go up and down? I'm not sure if using BodyVelocity is the right way to make a fly but how do I stop the levitation? My code is
game:GetService("UserInputService").InputBegan:Connect(function(KeyDown, gameProcessed)
if not gameProcessed then
if KeyDown.KeyCode == Enum.KeyCode.E then
local bv = Instance.new("BodyVelocity", game.Players.LocalPlayer.Character.HumanoidRootPart)
bv.Velocity = Vector3.new(0, 5, 0)
bv.Velocity = Vector3.new(4000, 4000, 4000)
end
end
end)

1 comment
BodyVelocity will automatically force your velocity to be some given number (well, vector3). If you wish to counteract gravity, use bodyforce instead, add and subtract to determine how the player should move. Alternatively, you could use bodvelocity for movement while setting gravity to 0 locally.