Anybody know how to make my while loop run at the same time as the funtion or is this impossible :
local Debris = game:GetService("Debris")
local part = game.ReplicatedStorage.Part
local origin = workspace.Origin
local radius = 30
local function SpawnPart()
local speed = math.random(4, 16)/10
local height = math.random(4, 16)/10
local horizontalSpeed = math.random(4, 16)/10
local lifeTime = 10
local targetPart = part:Clone()
targetPart.Parent = workspace.Aurora
targetPart.Position = origin.Position + Vector3.new(math.random(-radius/2, radius/2), math.random(-radius/2, radius/2), math.random(-radius/2, radius/2))
Debris:AddItem(targetPart, lifeTime)
local i = 1
while targetPart do
targetPart.Position = targetPart.Position + Vector3.new(.1*horizontalSpeed, math.sin(math.rad(i*speed))*height/36, math.sin(math.rad(i*speed))*height/36)
i += 1
task.wait(.001)
end
end
while wait(1) do
print("spawn")
spawn(SpawnPart())
end
Spawn is being printed once every 10 seconds instead of every second