How to make BodyPosition constant?

How do I make a BodyPosition keep a constant speed? Is there some kind of formula where I can keep a constant speed depending on where I click?
It seems to slow the part when I click close and speed the part when I click far.

local mouse = game.Players.LocalPlayer:GetMouse()

local HS = game.Workspace:WaitForChild("Heavy Soldier")
local BG = HS:WaitForChild('Torso'):WaitForChild('BodyGyro')
local BP = HS:WaitForChild('Torso'):WaitForChild('BodyPosition')

	local mousPos = mouse.Hit.Position

	if (HS.Torso.Position - mousPos).Magnitude <= 25 then
		BP.Position =, mousPos.Y, mousPos.Z)
		BG.CFrame =,, 1, mousPos.Z))

Instead of using a BodyPosition, try using a BodyVelocity.

1 Like

I’ve tried using BodyVelocity but I can’t figure out how to make it work with mouse.Hit.Position.

BodyVelocity.Velocity = _SPEED_ *, mousePos).LookVector

Then do a check every frame or so for the distance. Once the distance is less than a certain threshold then remove the body velocity or set it to 0, 0, 0.

Are you making a game like The Conquerors?

1 Like

It’s an RTS, yes. The only similarities the two games have is the movement.
It seems to only move when my own character is within a certain distance of the unit… what?

local mouse = game.Players.LocalPlayer:GetMouse()

local HS = game.Workspace:WaitForChild("Heavy Soldier")
local BG = HS:WaitForChild('Torso'):WaitForChild('BodyGyro')
local BV = HS:WaitForChild('Torso'):WaitForChild('BodyVelocity')
BV.MaxForce =, math.huge, math.huge)
--local BP = HS:WaitForChild('Torso'):WaitForChild('BodyPosition')
--BP.MaxForce =, math.huge, math.huge)

local speed = 8

local function checkPoint(destination)
	while true do
		local distance = (HS.Torso.Position - destination).Magnitude
		if distance <= 1 then
			BV.Velocity =, 0, 0)

	local mousePos = mouse.Hit.Position
	if (HS.Torso.Position - mousePos).Magnitude <= 100 then
		print(mousePos, (HS.Torso.Position - mousePos).Magnitude)
		--BP.Position =, mousPos.Y, mousPos.Z)
		BG.CFrame =,, 1, mousePos.Z))
		BV.Velocity = speed *, mousePos).LookVector

No where is my own character included… But the unit moves only when I am near it.

I had this issue, it has to do with physics updating on the client. If you are producing parts on the client then it should be fine, but if you are cloning an unanchored part that the server controls in the workspace then this might happen. If you are cloning things, make sure you anchor before cloning so you don’t get this funny physics behaviour (then you can unanchor it).

In your case you are waiting for something on the server side (your troops I guess), no cloning involved. You would have to set NetworkOwnership so the server knows you are in control of those things. It’s not the same case as mine but the root cause is the same; unanchored parts controlled by the server have the server as the network owner. If the client tries to control those parts then you get funny behaviour.

Wouldn’t the simple fix just use a RemoteEvent and move BodyVelocity and such to the server side?

1 Like

You could do that yes. It would be smoother on client side (no lag) but yeah you could just do it from the server to avoid NetworkOwnership headaches.

It’s also a good way to avoid exploiters flinging their armies around the map at other players.

1 Like

How would I set NetworkOwnership to the model serverside?
Wouldn’t I need a RemoteEvent anyway in order to set it to the server?

If the server creates the armies, then automatically I believe the server is in charge of them. If you want to be sure you can set NetworkOwner to nil for the server to be in charge.

The RemoteEvent thing depends on how your game is set up. I would assume that if you generate armies on the server then they wouldn’t need a RemoteEvent other than for the player to communicate where to move them.

Ah! I set NetworkOwnership of the soldier model to the player, now it works.
What does it do?

1 Like

It just moves the physics calculations to the client. Without it, it takes the nearest player *sometimes (it’s undefined behaviour in my opinion) and the physics calculations are replicated to everyone else. When the server is in charge, it doesn’t have a player to refer to so it does the calculations for everyone. If you have it set locally then you control that part over the entire workspace. I think the reason for the distance thing is that if there’s physics that isn’t local that is “far away” then it shouldn’t matter to the player that much so it doesn’t play out until you get nearby.

It’s weird behaviour but there’s a few ways to deal with it like we discussed. Glad that it worked out

1 Like

Would a game like The Conquerors 3 be putting each teams soldiers as their own client network ownership?

I’m not sure. I used to play The Conquerors 3 (and the older versions back in the day) but I’m not sure how it is implemented. There is some input lag last I remember so it is likely server sided.

1 Like

Im the developer of TC3

No, the server owns all physics in the game. Both for security purposes and to avoid issues with sleeping parts where objects wont move when intended if theres no player near them.

Interesting. I assume you just moved the units server-sided via RemoteEvents?
How do I make it so the player doesn’t need to be near the unit to move it?

I dont know how to force physical parts to react to physics, ie not sleep, other than setting the ownership to the server. Something youll want to do anyway.

Yes I use remote events

1 Like