Bodyvelocity help

trying to alter the “x” part of the Velocity property of a BodyVelocity via script

getting an error, “X cannot be assigned to”

script:

	local bv = Instance.new("BodyVelocity")
	bv.Parent = (Player.Character.RightFoot)	
	bv.MaxForce = Vector3.new(10000000,10000000,10000000)
	bv.P = 7000000000000	
	bv.Velocity.X = -900

there’s more to the script which has functions to get the player and things, but this is just about the body velocity issue

You can’t set specific parts of properties like that I think, instead to get your intended effect you should do:

local bv = Instance.new("BodyVelocity")
bv.Parent = (Player.Character.RightFoot)	
bv.MaxForce = Vector3.new(10000000,10000000,10000000)
bv.P = 7000000000000	
bv.Velocity = Vector3.xAxis * -900 -- Equal to Vector3.new(0, 0, -900)

However, I would recommend not using BodyVelocity as it has been superseded by LinearVelocity (roblox.com).

i don’t understand linear velocities or any of the new ones, body velocity is just easier for me. thanks for your help!

LinearVelocity is actually easier to use than BodyVelocity once you understand them.

To make a simple one, all you need to do is:

local attachment = Instance.new("Attachment")
attachment.Parent = part 

local linVel = Instance.new("LinearVelocity")
linVel.Attachment0 = attachment
linVel.MaxForce = math.huge -- Will be able to push anything
linVel.RelativeTo = Enum.ActuatorRelativeTo.World -- World or attachment[0/1]
linVel.VectorVelocity = Vector3.new(0, 0, -900) -- Or whatever you want
linVel.Parent = part

If you have any further questions about LinearVelocity I’m happy to help. I also had some issues getting started with them initially.

By the way; all of the new BodyMovers work in this way. All of them require an attachment.

how would i move something to the right using a linear velocity? im trying to do that with the body velocity

I don’t know off of the top of my head which axis is to the right, but something along these lines:

local attachment = Instance.new("Attachment")
attachment.Parent = part 

local linVel = Instance.new("LinearVelocity")
linVel.Attachment0 = attachment
linVel.MaxForce = math.huge -- Will be able to push anything
linVel.RelativeTo = Enum.ActuatorRelativeTo.Attachment0 -- Relative to your part

linVel.VectorVelocity = Vector3.xAxis * -900
-- Not sure if the above is to the right, change the axis to yAxis or zAxis until it goes to the right or left.
-- If it goes to the left, make -900 positive (900)
linVel.Parent = part

thank you!! i will try it

eewewewewewe for characters

1 Like

they’re spinning around on the floor…?

i tried the -900 and it was too powerful so i dropped it to -10 and now they’re spinning lol

https://gyazo.com/0b55a1f5596d899eeb26c8b699f19e09

I did not expect that, the ending caught me off guard lol

The force will be applied on the attachment, if you chose a pre existing attachment (none of which are at the center of the humanoid) then the force won’t be applied at the center.

Try creating a new attachment at the center of HumanoidRootPart

i created an attachment at the center of humanoidrootpart, it worked!

thank you :smiley:

1 Like