I have a return but the code still works with or without it. I needed this function to work with a return.

--Random price generator
local function randomPriceGenerator(carPriceArray)	
	while priceRndGeneratorCount < 3 do
		local rnd = Random.new()
		local price = rnd:NextInteger(1,3) -- Generate a random number between 1 and 3
		--Add price to the array
		table.insert(carPriceArray, price)
		priceRndGeneratorCount  = priceRndGeneratorCount + 1
	end	
	return carPriceArray --Return to value/s the carPriceArray
end





--Price Array
local carPriceArray  = {}

--Calling the randomgenerator function
randomPriceGenerator(carPriceArray)	

-- Price and name of the cars array
local carsInfo = {

	["CarOneName"] = "Car 1",
	["CarOnePrice"] = carPriceArray[1], --Retrieve price from carPriceArray

	["CarTwoName"] = "Car 2",
	["CarTwoPrice"] = carPriceArray[2], --Retrieve price from carPriceArray

	["CarThreeName"] = "Car 3",
	["CarThreePrice"] = carPriceArray[3] --Retrieve price from carPriceArray

}