I am trying to make the player fall faster while holding shift, here is some code I’ve already tried:
local char = script.Parent
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(key)
if key == Enum.KeyCode.LeftShift and char.Humanoid.HumanoidStateType == Enum.HumanoidStateType.Freefall then
char.BodyVelocity.Y = -90
UIS.InputEnded:Connect(function(key)
if key == Enum.KeyCode.LeftShift and char.Humanoid.HumanoidStateType == Enum.HumanoidStateType.Freefall then
char.Humanoid.Velocity.Y = -16
end
end)
end
end)
This doesn’t work, and doesn’t give any errors, it is a server script in StarterCharacterScripts.
As a side note, what happened to BodyMovers, do they not exist anymore? I haven’t seen a tutorial or any content made on them after 2020.
UIS.InputBegan:Connect(function(key)
if key == Enum.KeyCode.LeftShift and char.Humanoid.HumanoidStateType == Enum.HumanoidStateType.Freefall then
char.BodyVelocity.Y = -90
UIS.InputEnded:Connect(function(key)
if key == Enum.KeyCode.LeftShift and char.Humanoid.HumanoidStateType == Enum.HumanoidStateType.Freefall then
char.Humanoid.Velocity.Y = -16
end
end)
end
end)
You’re creating another function in an IF statement which is also in another function. I would suggest making that InputEnded function a whole different function outside of the InputBegan and if statements.
You’re unable to change an axis by itself, the only thing that will do is return a number, thats all, to Apply a new force on Axis while maintaining the old on the other, you should do this:
local Vel = char.Humanoid.Velocity -- Velocity
char.Humanoid.Velocity = Vector3.new(Vel.X, Vel.Y - 16, Vel.Z) -- Keeps old Values while updating the Y value
Plus, Velocity is deprecated and should be replaced with AssemblyLinearVelocity