Function refusing to run?

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

This is your loop:

while true do
spawnenemy()
wait(2)
end

Change it to this:

print("This is the last line of code before the loop")
while true do
print("Running the loop")
spawnenemy()
wait(2)
end

Check and share the results.

Why are you setting CanCollide to false, just set the base model like that if you want. You should probably use :SetPrimaryPartCFrame() instead of doing it like that

i figured it out myself, i had a line that was:

repeat
wait()
until game:IsLoaded()

this is why it didnt work, i deleted this from the script and it started the work again, thanks for the feedback tho!