How To Stop Character From Getting Stuck In Roof With BodyVelocity

Hello everyone,
I am working on a script where you get a large jump when you touch a jump pad, but whenever the player uses the large jump under a roof the top of their head gets stuck in a roof for .5 seconds and then they fall off. I have tried destroying the BodyVelocity by using a raycast to check if there is anything above the players head but the jump boost is too quick because I run the raycast every RunService.Stepped and by the time its in the .5 stud distance it needs for the raycast to find the roof the player will be stuck in the roof.

Are you using BodyVelocity to give the player a jump boost?

Have you tried using the Humanoid Property JumpPower? Maybe it will suit your needs better than BodyVelocity and it might fix this issue.

1 Like

No its when the player jumps on the jump pad

Oh, hm… You can do something else instead of RunService.Stepped to check whether or not to destroy the BodyVelocity.

You can add BodyVelocity to be destroyed after a specific period of time (that way the jump from the jump pad won’t last forever).

Try disabling RunService.Stepped and try this:

task.delay(1, function()
objectToClean:Destroy()
end)

you can replace 1 with the time to wait before destroying the BodyVelocity (depending on how you want it to work) and make sure to replace the objectToClean with the path to your BodyVelocity.

1 Like

I know but then the player will be stuck in the roof until it gets automatically destroyed

Set Humanoid.RootPart.AssemblyLinearVelocity directly or use Humanoid.RootPart:ApplyImpulse() instead of using a BodyVelocity. If you only need to apply force when the player steps on the jump pad, there is no reason to use a body mover or physics constraint.

2 Likes

Will it fix the issue though? Also if I change it to AssemblyLinearVelocity will the behaviour change?

How high is the MaxForce on the Y axis for the velocity?
I usually use MaxForce = Vector3.new(20000,40000,20000) for a normal sized rig.

1 Like

About 0,50000,0

sorry charlimit

Oh okay. By getting stuck, do you mean like stuck inside the roof and not falling down for a bit?

Also try lowering maxforce to 30000 and see if it makes any change.
Even after destroying the bodyvelocity, the character’s velocity will still be decreasing instead of going to 0.
Try setting the velocity of the character or the bodyvelocity to 0 too instead of deleting it.

1 Like

Apparently the correct MaxForce is BodyVelocity.P * Velocity so if I lower the MaxForce then the jump pad may give less of a boost. Is this formula correct?

Yeah, it should fix the issue. BodyMovers apply a constant force to an assembly - hence why player characters continue to rise when they hit a ceiling and seemingly get stuck. : ApplyImpulse() only applies a force once - characters will hit the ceiling and bounce off as they would normally.

To calculate the required force, use the formula Humanoid.RootPart.AssemblyMass * workspace.Gravity * JUMP_BOOST_HEIGHT.

It will feel different, but it will likely feel better and more natural for most players.

2 Likes

The maxforce is dependent on the total mass of every part in the character.

For example, you can use maxforce to make a blackhole.
The larger your character is, the less effect the velocity that the blackhole applies has on your character. But if you’re the size of an ant, it’ll easily pull you.

1 Like

Also instead of immediately deleting the bodyvelocity, try this out:

BODYVELOCITY.Velocity = Vector3.new(0,0,0)
task.wait()
BODYVELOCITY:Destroy()
1 Like

The reason why setting velocity of character to 0 won’t fix it is because its not that destroying bodyvelocity isnt working but its because the runservice.stepped raycast loop won’t catch when the player is near the roof, but ill add that anyways

Also can I get an image of what’s happening?
Why are the jump boosts giving the players a concussion on the roof? :joy:

1 Like


its very very slight

A few people have suggested before, but have you tried using:

Character.PrimaryPart.AssemblyLinearVelocity = VELOCITY

I’m guessing bodyvelocity persists a bit too long and you’ll just be smashed onto the roof until it deletes itself.

Edit: Also I’m in school right now and the connection is terrible. Video can’t play for me. (but that’s fine)

:star: Edit 2: AssemblyLinearVelocity should work the same except it’ll only apply once and your velocity is free to change as you interact and collide with stuff (meaning you should just bounce off the roof slightly instead of getting stuck).

2 Likes

How do give 2 people a solution?

You can’t unfortunately. :pensive:
30charlimitaaaaaaa

I did provide some more info which will be helpful to others with similar issues though.

1 Like