BodyPosition doesn't affect the part

Hello developers! So I am working on my horror game and I use BodyPosition for my AI, this is my quick module that I made, but the character doesn’t seem to work, or BodyPosition doesn’t affect the part, here’s my module :

local module = {}

module.__index = module
module.__moveToFinishedEvent = Instance.new("BindableEvent")
module.MoveToFinished = module.__moveToFinishedEvent.Event
module.speed = 16
module.speedIncrement = 100

script.Parent.BodyPosition:GetPropertyChangedSignal("Position"):Connect(function()
	repeat task.wait() until (script.Parent.BodyPosition.Position - script.Parent.Position).Magnitude < 1
	module.__moveToFinishedEvent:Fire()
end)

game:GetService("RunService").Heartbeat:Connect(function()
	local realSpeed = math.clamp((script.Parent.Position - script.Parent.BodyPosition.Position).Magnitude - module.speed,math.round(module.speed / 4),module.speed)
	print(realSpeed)
	script.Parent.BodyPosition.MaxForce = Vector3.new(realSpeed * module.speedIncrement,realSpeed * module.speedIncrement,realSpeed * module.speedIncrement)
end)

function module:MoveTo(position : Vector3)
	if not position then return end
	script.Parent.BodyPosition.Position = position
end

return module
1 Like

The part may be anchored, or be welded to an anchored part, otherwise it may be a problem with the :MoveTo() function.

No, part is unanchored and It isn’t welded to any part, it just falls into void. As it has normal physics.

Try setting max force to (inf, inf, inf) and see if it works. If so, not enough force.

Somehow it fixed itself. Maybe it was of wrong force setting.

1 Like