Shotgun jumping?

Im making a game and want my gun to push you up when you shoot down, any help with this? (If you can sudo code or give me examples that would be nice.)

1 Like

As I’m not sure of any examples I can give you brief sudo code.

The shotgun is triggered →
If the player’s camera CFrame angle is looking down then do the following →
Add velocity to the body to go up with x amount of force

Im lost body force was removed and replaced with LinearVelocity but no-one knows how to use it and the only tutorial dosent work… :frowning:

BodyForces weren’t removed, you can still create them through scripts.

To apply shotgun pushback, you need to firstly get camera’s LookVector
Once you have the LookVector you have the a Vector3 value of the way that camera is looking.

With this you want to modify the Z value of to create the pushback force and apply it to your character’s BodyVelocity instance that you should have created inside of the Torso. You should nullify other values like the X and Y.

Example:

LookVector: (1, 0.5, 0.25)
Our new lookvector: (0, 0, 0.25)
Our new modified Z vector (0, 0, -0.25) - I multiplied it by -1, you can do any bigger negative number.
Apply it to our BodyVelocity Instance.

Note: When doing this you want to probably delete the instance .1 seconds.

1 Like

so would I do instance:new(“body force”)?

You would type same thing as you would if you were inserting one manually, I use bodyvelocity for this.

I found this script, is there any reason this wont let me go upward?

				local PlayerOrientation = Player.Character.HumanoidRootPart.CFrame.LookVector 
				local VelocityModifier = 50 
				local MaxForce = Vector3.new(50000,50000,50000)


				local bodyVelocity= Instance.new('BodyVelocity')
				bodyVelocity.Parent = Player.Character.HumanoidRootPart
				bodyVelocity.MaxForce = MaxForce
				bodyVelocity.P = math.huge
				bodyVelocity.Velocity = Vector3.new(-PlayerOrientation.X*VelocityModifier,-PlayerOrientation.Y*VelocityModifier,-PlayerOrientation.Z*VelocityModifier)

				game.Debris:AddItem(bodyVelocity,0.1)

It’s using RootPart LookVector not your cameras.

How would I change it to camera?

Since shooting will always be in front of the player, you can easily just get the shooting direction and inverse it

HumanoidRootPart.Velocity = ShootingDirection * -50

What do you mean nobody knows how to use it, just read the documenation… Also it’s a replacement for bodyvelocity not body force.

Why is this not working?
playerName is the player name

game.Workspace:WaitForChild(playerName).HumanoidRootPart.Velocity = game.Workspace.CurrentCamera * -50

There is not enough impulse
Use BodyVelocity

Im new to this stuff and this is my first time, how do I use BodyVelocity?

I figured it out but it wont work…

game.Workspace:WaitForChild(playerName).HumanoidRootPart.BodyVelocity.velocity = Vector3.new(0,-1.5,0)

You might want to increase the MaxForce on it as it doesn’t have enough force to lift your character. Set it to something like 1000000, and if it doesn’t work, try adding a zero.

It says BodyVelocity isint a member of root part

local BodyVelocity = Instance.new("BodyVelocity",HumanoidRootPart)
BodyVelocity.Velocity = game.Workspace.CurrentCamera * -50
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
game.Debris:AddItem(BodyVelocity,0.5)
2 Likes

I fixed it myself thanks anyways :smiley: