Help with BodyPosition

hello, i dont quite understand how bodypositions work.

can anybody explain why this isnt working?

wait(2)
for i, v in pairs(players:GetChildren()) do
	local HumanoidRootPart = v:FindFirstChild("HumanoidRootPart")
	
	local BP = Instance.new("BodyPosition",v)
	BP.MaxForce = Vector3.new(25000,25000,25000)
	BP.P = 100
	BP.D = 100
	BP.Position = Vector3.new(10,0,0)
end
1 Like

You’re parenting the body position to the player instead of the HumanoidRootPart.

local BP = Instance.new("BodyPosition",v)

Should be

local BP = Instance.new("BodyPosition",HumanoidRootPart)

You may need to up the P value. Also I don’t recommend using the second argument in Instance.new(), instead parent the BodyPosition like this:

BodyPos.Parent = v.PrimaryPart

this still doesnt work unfortunately, my character just stands there

wait(5)
print("exectued")
for i, v in pairs(players:GetChildren()) do
	local HumanoidRootPart = v:FindFirstChild("HumanoidRootPart")
	
	local BP = Instance.new("BodyPosition")
	BP.Parent = HumanoidRootPart
	BP.MaxForce = Vector3.new(25000,25000,25000)
	BP.Position = Vector3.new(20,0,0)
	BP.P = 100000
	BP.D = 100
	
end``` i did this but it still doesnt work

Try to up the power and decrease the dampening (D). Also try increasing the max force.

wait(5)
print("exectued")
for i, v in pairs(players:GetChildren()) do
	local HumanoidRootPart = v:FindFirstChild("HumanoidRootPart")
	
	local BP = Instance.new("BodyPosition")
	BP.Parent = HumanoidRootPart
	BP.MaxForce = Vector3.new(25000,25000,25000)
	BP.Position = Vector3.new(20,0,0)
	BP.P = 1000000
	BP.D = 1
	
end

this still doesnt work unfortunatelty!

This isn’t working because you are checking the player for the HumanoidRootPart.

local HRP = v.Character.PrimaryPart

BodyPos.Parent = HRP

Oops, you aren’t checking the Character for the HumanoidRootPart, you’re checking the player specifically. To fix this, do v.Character:FindFirstChild("HumanoidRootPart").

it is better to parent the bodyPosition after you configure all the properties.

I’m aware, others have already told OP that parenting after setting all the properties is better memory wise and instance wise.