Thanks for the extra info. Here is the enemy spawn code:
for i = 1, amount do
task.wait(0.5)
local CloneOfRequestedEnemy = RequestedEnemy:Clone()
local MapTroopSpawnCFrame = MapTroopSpawn.CFrame
local CFrameToMoveTo = CFrame.new(MapTroopSpawnCFrame.X, MapTroopSpawnCFrame.Y + 10, MapTroopSpawnCFrame.Z)
CloneOfRequestedEnemy.HumanoidRootPart.CFrame = CFrameToMoveTo
CloneOfRequestedEnemy.Parent = workspace.EnemiesFolderGame
for index, value in CloneOfRequestedEnemy:GetDescendants() do
if value:IsA("BasePart") then
value.CollisionGroup = "Enemy"
end
end
CloneOfRequestedEnemy.HumanoidRootPart:SetNetworkOwner(nil)
task.defer(function()
Package.MoveEnemyThroughWaypoints(CloneOfRequestedEnemy, mapToSpawnOn)
end)
end
Here is the code that moves the enemy to each waypoint:
function Package.MoveEnemyToPoint(enemyHumanoid: Humanoid, waypointToMoveTo: Part)
enemyHumanoid:MoveTo(waypointToMoveTo.Position)
enemyHumanoid.MoveToFinished:Wait()
end
Using Tweens isn’t exactly a solution as they do not play animations, and are not as configurable.
I think the problem is that MoveTo does not respect Scale, which I am using to scale down the enemies. I think the best idea would be to add an offset of the enemy’s position the way they are looking.
Yeah I just tried this, they just stop in front of the point where they are supposed to go. I am going to try my previous solution and see if that works. I am just not sure how I would get the orientation they are looking at and move them forward a bit.
yeah you could also do this. not sure on if it changes alot on scale with waypoint use. I know it does effect the humanoids physics and speed if scaled enough either way
If that’s the case, then I would have the client tween the enemies on reaching their destination while the server teleports the enemies exactly to their destination through remote event. It’s gonna be server-to-client, so exploiters can’t really do anything about that.
can you not do another moveto for the offset location? and other than that to make things smooth you might could use AlignPosition and AlignOrientation those are the only other ways of moving and these can also be used for up to about 1k pets in a game at one time controlled by one client
The server tells the client their current position before teleporting them, so the client teleports the enemy back to their original position, and tween it.
I just noticed this. I do not recommend assigning a name to index in for loops if you’re not gonna use it. This can cause memory leaks, therefore, a bad practice. Many programmers commit this mistake, and professionals are aware of it.
Instead, assign it with underscore, in other words, a dash (_). It does nothing other than mark it as unused variable, which saves memories.