Files
utd/TrackLogic.lua
T
2025-07-25 11:28:47 -05:00

38 lines
987 B
Lua

local RunService = game:GetService("RunService")
local Waves = require(script.Parent.Waves)
local waypoints = { -- Fill with your waypoint Parts
workspace.Waypoint1,
workspace.Waypoint2,
workspace.Waypoint3,
-- etc.
}
local enemies = {} -- Table to hold TrackEnemy objects
local function spawnWave(waveData)
coroutine.wrap(function()
for _, group in ipairs(waveData) do
for i = 1, group.count do
local enemyModel = group.model:Clone()
enemyModel.Parent = workspace
local enemy = TrackEnemy:new(enemyModel, group.name, group.health, group.speed)
end
if group.delay and group.delay > 0 then
wait(group.delay)
end
end
end)()
end
spawnWave(Waves[1])
RunService.Heartbeat:Connect(function(dt)
for i, enemy in ipairs(enemies) do
if enemy.alive then
enemy:moveToWaypoints(waypoints, dt)
end
end
end)