Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[ANSWERED] How to make BodyVelocity only change 1 axis velocity?

Asked by 5 years ago
Edited 5 years ago

The question says it all. How would I make BodyVelocity only change 1 axis? The BodyVelocity is in the players head and I am trying to make the player go up at a constant rate when they press SPACE without affecting their WASD movement (x and z-axis) but, when in mid-air, their WASD movement gets suspended and they travel up only. How can I make it so that body velocity only affects their y-axis?

I tried this:

local bodyvelocity = Instance.new("BodyVelocity")
bodyvelocity.Parent = character.Head
bodyvelocity.P = 1000

mouse.KeyDown:connect(function (key)
    key = string.lower(key)
    if string.byte(key) == 32 then
        spacedown = true
        bodyvelocity.Velocity = Vector3.new(0,1,0)
    end
end)

This is in a Local Script in the player. 'character' and 'mouse' are defined. The script works but when flying up, the player can no longer use WASD to move their x and z-axis. How would I make the BodyVelocity only affect the y-axis and still allow WASD movement?

2
Try set MaxForce to Vector3.new(0,1,0)*SomeReallyBigNumber Protoduction 216 — 5y
0
oh wow thanks for that. It works now, if you make this into an answer i will accept it for you if u want more reputation dadysherwin2 155 — 5y
0
Thanks so much! this helped with a jet pack :D codingMASTER398 52 — 4y

Answer this question