so im making a tower defense game, but when i played, the enemies didnt spawn, so i checked the script that spawns the enemies and the function that spawns them in is called but nothing happened, i even put “print(“spawned enemy”)” and it still didnt work, the function was called, but it “refused” to run, and the script is not disabled, plus its a server script and in serverscriptservice
here is the code:
function spawnenemy()
print("spawned enemy")
local options = {enemies.Enemy,enemies.Enemy2}
local entity = options[math.random(1,#options)]:Clone()
entity.PrimaryPart.CFrame = path.CFrame
entity.Parent = workspace.Enemies
for _,part in pairs(entity:GetChildren()) do
if part:IsA("BasePart") then
part.CanCollide = false
end
end
end
also this is just the function that spawns the enemies, the whole script is much bigger, here are the lines that call the function:
while true do
spawnenemy()
wait(2)
end
im confused