How do I check when the player's Magnitude has changed to X while freefalling?

I’ve been working on this portion of my script for a couple hours, and I can’t find anything that might help with detecting when the magnitude changes to X (let’s say a magnitude of 90) when the player enters into freefall.

I’ve looked for similar solutions, but none of what I’ve found on the devforum were relevant to magnitude. For the time being, I’m taking certain aspects of other scripts shared among the devforum and editing them to make this example.

I’ve tried a variety of methods, but I can’t find any type of solution for it. I know it’s possible, but I just don’t understand how I can make this happen as of now.

Any and all help is appreciate, here’s my code:

local character = script.Parent
local username = character.Name
local humanoid = character.Humanoid
local rootPart = humanoid.RootPart or character.HumanoidRootPart

local magnitude = math.abs(math.round(rootPart.Velocity.Magnitude))
local damageMagThreshold = 90
local falling
local ragdolled, canGetUp = false, true

--Only starts when I leave the suggested state
humanoid.StateChanged:Connect(function(oldState, newState)

--[[Detects when the player is freefalling, as opposed to 
starting when it has reached >= damageMagThreshold]]
	if newState == Enum.HumanoidStateType.Freefall and not ragdolled then
		ragdolled = true
		canGetUp = false
		task.delay(1, function()
			canGetUp = true
		humanoid.AutoRotate = false
		humanoid.PlatformStand = true
		--ragdoll function

You can listen to the AssemblyLinearVelocity changed event and check the magnitude then.


I don’t see any Changed event linked with AssemblyLinearVelocity, what is it paired with in a line of code in mention of a part?

You can listen for the AssemblyLinearVelocity property as @azqjanna said. This means using a property changed signal listener.

Instance:GetPropertyChangedSignal(“Property”) Documentation

In your case, you would want to get the root part’s AssemblyLinearVelocity property changed signal, which will fire whenever the player is moving. You can then use the magnitude at that given time to check when the player is freefalling.

1 Like

You can use the Players.CharacterAdded event to detect when a player’s Magnitude has changed. The event is triggered whenever a player’s Magnitude changes. You can then use the Player.Character property to access the Character and its Humanoid object, which contains a MaxForce property that stores the current Magnitude value.

I’ve been having trouble understanding what you mean, I’ve also been playing with it to see how it works, but the behavior I’ve been observing is that, when I change the velocity itself with a block of code, that’s the only time where it prints. I feel there’s something I’m missing here that I’m ignorant to; how would I go about applying this to achieve my goal?

If i’m not mistaken if you want to detect a change in a player’s magnitude AKA movement you should be
detecting it using Humanoid.MoveDirection

This code right here detects the Character’s change in movement only if they’re free falling
and then stop detecting the change if the Humanoid is not freefalling, to avoid a memory leak.

local Connections = {}

humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Freefall then
		Connections["MagnitudeChange"] = humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function() 
			print("Player is moving while freefalling")
		-- If the player is not free falling then stop detecting the change in movement
		if Connections["MagnitudeChange"] then

No, I already covered that. I went into deeper detail in the original post, but I’m looking for when the rootPart hits a total magnitude of 90 or more while freefalling.

Can you explain what you mean by magnitude of 90?

Magnitude; a unit that stands for the summation of the total velocity value as a single number value. Magnitude can be an integer, or a float based on the calculations you make (integer in this case for simplicity).

To apply this to the script, I’m trying to configure it to where the script detects when the magnitude/total velocity is greater than or equal to a set example; such is 90.

Wouldn’t it be something like

I’ve tried that, but whenever I try to detect it that way, it always renders either after the state changes or doesn’t render at all; never mid-air at 90.

The closest I could get was 50, which is not suitable at all for the game I’m trying to make.

If the closest you could get is 50, that means terminal velocity is 50. Adjust your parameters

I’ve tested the terminal velocity can be as much as little under 300 from what I’ve gathered. There’s no terminal velocity being reached until then. 90 is within the range 0 - ~300, which is what I’m stuck on.

if listening functions are not working you can always manually calculate velocity using physics equation using distance and time to obtain velocity

using this should work though


obtaining assemblylinearvelocity every runservice.stepped until whatever condition should do the job.

So far, with my scripting knowledge, I can’t get this method to work for me either.

this should help you get started

game["Run Service"].Stepped:Connect(function()
	local Player = game.Players:FindFirstChildOfClass("Player")
	if Player then
		if Player.Character then
			local HRP = Player.Character:FindFirstChild("HumanoidRootPart")

			if HRP then

				print((, HRP.AssemblyLinearVelocity.Y, 0)).Magnitude)

1 Like

Turns out, this actually helped. I looked more into this, and cooked up a result I’m very happy with.

Whoever finds any flaws with this script, or it becomes outdated, please contact me directly, or post on this board so I can update it as the most efficient result (Consider it a challenge :joy:)

local interval = .1
local elapsed = 0

function ragdoll()
	--Your ragdoll system here

humanoid.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Freefall then
		print("Falling; starting check")
		game["Run Service"].Heartbeat:Connect(function(deltaTime)
			elapsed += deltaTime
			if elapsed >= interval then
				elapsed -= interval
				magnitude = math.abs(math.round(rootPart.Velocity.Magnitude))
				if magnitude >= 90 and not ragdolled then

^^ Whoever wants to experiment with the script, go right ahead

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.