yeah its just they dont look at the next point
Give me a minute and I’ll fix that
1 Like
for i = 1, 3 do
local Test = game:GetService("ServerStorage").Enemies.Test:Clone()
Test.Parent = workspace.Enemies
Test:PivotTo(workspace.EnemySpawn.CFrame)
local previous_waypoint = workspace.EnemySpawn
coroutine.wrap(function()
for currentpoint = 1, #workspace.Pathpoints:GetChildren() do
local distnace = (previous_waypoint.Position - workspace.Pathpoints[currentpoint].Position).Magnitude -- distance calculation
local speed = Test:GetAttribute("Speed") -- enemy speed
local TravelTime = distnace
— Rotation —
Test.PrimaryPart.CFrame = CFrame:lookAt(Test.PrimaryPart.Position, workspace.Pathpoints[currentpoint].Position)
local info = TweenInfo.new(
TravelTime,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out
)
local tween = TweenService:Create(
Test.PrimaryPart,
info,
{CFrame = workspace.Pathpoints[currentpoint].CFrame}
)
tween:Play()
tween.Completed:Wait()
previous_waypoint = workspace.Pathpoints[currentpoint]
end
Test:Destroy()
end)()
task.wait(0.5)
end
thank you so much this works perfectly but one thing is you forgot
local TravelTime = distance/speed
you only put = distance
Yeah the forum code editor for mobile is so hard to work with