Making a roll without VectorForce or BodyVelocity?

I’m making a roll and using VectorForce to do it, issue is that it’s wayyy too buggy and changes constantly. For example when I roll on the ground it pushes me forward fine, but when I roll in the air it pushes me way further than when I was on the ground, or when I roll with a tool it makes me travel significantly shorter than if I were to roll normally. I need an alternative.
The script is client-side & is in StarterCharacterScripts.

uis = game:GetService('UserInputService')
char = script.Parent
hrp = char:WaitForChild("HumanoidRootPart")
canRoll = true
uis.InputBegan:Connect(function(input, isTyping)
	if isTyping or canRoll == false then return end
	if input.KeyCode == Enum.KeyCode.Q then
		canRoll = false
		local vel ='VectorForce', hrp)
		local attach ='Attachment', hrp)
		vel.Name = "RollForce"
		attach.Name = "RollAttachment"
		vel.Attachment0 = attach
		vel.RelativeTo = Enum.ActuatorRelativeTo.World
		vel.Force = hrp.CFrame.LookVector*15000
		game.Debris:AddItem(vel, 0.2)
		game.Debris:AddItem(attach, 0.2)
		canRoll = true

Edit: I am willing to use VectorForce if there is a way of making it less buggy.

There should be an alternative way for doing this. So my idea is, you can use ContextActionService that binds with your roll mechanic. Once it runs, you lerp HumanoidRootPart forwards to where the player is facing using CFrame. At the same time, you create a rolling animation. You can add some debouncing value to make sure that the player cannot reroll when they are already rolling.

1 Like

I don’t recommend you to use any bodyMovers for this type of thing, as you can tell it’s less reliable and can vary sometimes. I made a similar system recently, what I did was just offsetting the character’s HumanoidRootPart CFrame by a specific amount inside a for loop. This way it’s not dependant on physics. Then you can use raycasting to check if the player is close to a wall and stop before they go through. Hope it helps!

1 Like

for in air, try this:

If char.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
      hrp.Velocity += hrp.CFrame.LookVector.Unit * 100
1 Like

Tried this and it works perfectly! Thanks for the advice everyone!

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