For loop help and coroutine

image

how i can get one car in loop

local Tween		 = game:GetService("TweenService")
local Roda  	 = game.Workspace.Roda
local Spawner 	 = Roda.Spawner
local Target 	 = Roda.Target
local tweenInfo  = TweenInfo.new(100, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local TraficCars = game.ServerStorage.TraficCars:GetChildren()

local SpawnCars = coroutine.create(function()
	while wait(5) do
		for Number,cars in TraficCars do
			if cars :IsA("MeshPart") then
			
			
			print(cars)
			
			
			end
		end
	end
end)

You want to get 1 car from the loop? What would you do with it, does it have to be a random car all times? You could use local car = TraficCars[math.random(#TraficCars)] to get 1 random car, if that’s what you want.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.