VectorForce not working?

Recently I’ve switched from BodyForce to VectorForce, however I’m having some issues.

	local force ="VectorForce", projectile)
		local mass = 0
		for i,v in pairs (projectile:GetChildren()) do
			if v:IsA("Part") or v:IsA("WedgePart") then
				mass = mass + v:GetMass()
		force.ApplyAtCenterOfMass = true
		force.RelativeTo = "World"
		force.Force =, mass*workspace.Gravity, 0)
		force.Enabled = true

Why isn’t this code working? Could it be because the part I’m trying to apply it on is in a model?

You did not specify VectorForce.Attachment0 which every VF requires. Just create an attachment under the projectile and set the property to that. Also you can just use BasePart.AssemblyMass to get the mass of the model instead of looping through it’s children.

-- Avoid using the second argument of (
local force ="VectorForce")
local attachment ="Attachment")
	force.ApplyAtCenterOfMass = true
	force.RelativeTo = "World"
	force.Force =, projectile.AssemblyMass * workspace.Gravity, 0)
	force.Attachment0 = attachment
	force.Enabled = true

	attachment.Parent = projectile
	force.Parent = projectile

That worked, thank you so much.

1 Like