How do I make the player fall faster when pressing a button?

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.

1 Like

BodyMovers are actually deprecated, I’d suggest taking a look at:
linear velocity
or
vector force

Just wanted to point out in your code:

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.

Oops I didn’t mean to reply to you lol my bad

1 Like

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

Server scripts don’t work in StarterCharacterScripts, either put the script in ServerScriptService or convert it into a LocalScript.

server scripts do work in StarterCharacterScripts. You just cant use things like LocalPlayer

Yes you could:

local char = script.Parent
local Player = game.Players:GetPlayerFromCharacter(char)

Really, Its simple.

Is this in StarterCharacterScripts?? I thought only local scripts could run there.