Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make BodyVelocity only go in one direction ignoring the other directions?

		local Body = Instance.new("BodyVelocity",character.Torso)
		
		Body.Velocity = Vector3.new(0,25,0)

This will be hard to explain but but I want to use body velocity only in the Y direction. Something like the code above but it just ignores the z and x directions. When using (0,25,0) it does not allow you to move while going up.

5 comments

0

To reexplain I want my character to move up for a certain amount of time while still being able to move freely in the z and z directions.

0

Set the first and third parameters for MaxForce to 0. MaxForce = Vector3.new(0, 25, 0)

0

I am still really struggling with this, so I would have to set the MaxForce to 0 for the x and z? Will this allow me to still move while going up and how would I set them.

0

My new code might work?

0

very sorry that it did not work at first D:

1 answer

you could use regular velocity instead. I think that is what body velocity does anyway?

I have heard tell that regular velocity is hard to work with but have never experienced that myself.

Hope this helps!

EDIT2: My code did not work, something else you could try

while (your condition for flight is met) do wait ()

local Body = character.Torso

Body.Velocity = Body.Velocity * Vector3.new(1,0,1) -- sets the Y to 0
Body.Velocity = Body velocity + Vector3.new(0,25,0) -- increases it to 25 essentially setting Y to 25?

end

Please let me know if this method works, If it doesn't then I will remove my answer, (but really this should work now)

6 comments

0

Velocity.Y gets only the up/down direction (think of a Vector3 value as Vector3.new(X,Y,Z))

0

If this helps, accept answer :D

0

I didnt think about using Body.Velocity.Y, thanks!

0

I keep getting the same error when I try using that "Y cannot be assigned to"

0

The X, Y and Z axis's are read-only; to edit them, you have to use a Vector3.new. Velocity = Vector3.new

0

the pain of a -1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.