Cannot define Y

my script got an error
it says cannot define Y

local replicatedStorage = game:GetService("ReplicatedStorage")

local outFolder = workspace.Out

local values = {}

local copyOut = replicatedStorage.copyOut

local function getHighest()
	local highest = nil
	for _, value in pairs(values) do
		if not highest then
			highest = value
			continue
		end
		if value > highest then
			highest = value
		end
	end
	local beforePos = highest.Position

	local y = beforePos.Y
	local copyPoint = Vector3.new(58.212, y+30, -68.98)
	return copyPoint
end

local function newOut()
	local newOut = copyOut:Clone()
	for i=1, 1000, 1 do
		if not values[i] then
			newOut.Name = i
			table.insert(values, newOut.Name)
			newOut.Parent = outFolder
			newOut.Position = getHighest()
		else
		end
	end
end

newOut()

Maybe highest does not get set?

Do this:

local replicatedStorage = game:GetService("ReplicatedStorage")

local outFolder = workspace.Out

local values = {}

local copyOut = replicatedStorage.copyOut

local function getHighest()
	local highest = nil
	for _, value in pairs(values) do
		if not highest then
			highest = value
			continue
		end
		if value > highest then
			highest = value
		end
	end
    
    print(tostring(highest))
	local beforePos = highest.Position

	local y = beforePos.Y
	local copyPoint = Vector3.new(58.212, y+30, -68.98)
	return copyPoint
end

local function newOut()
	local newOut = copyOut:Clone()
	for i=1, 1000, 1 do
		if not values[i] then
			newOut.Name = i
			table.insert(values, newOut.Name)
			newOut.Parent = outFolder
			newOut.Position = getHighest()
		else
		end
	end
end

newOut()

and see if it prints anything other then nil.

it prints out 1
then it prints out the error

I believe your error is caused because of the line table.insert(values, newOut.Name) in the function newOut. That line says to insert the name (a string) of newOut into the table values. The function getHighest expects the elements of the table values to have a Position property, however strings do not have a Position property and that is why you are getting an error. If you change the line that inserts into the table to table.insert(values, newOut) then this should alleviate that error.

(Also, its good practice to not name your local variables the same as your functions :D)

local replicatedStorage = game:GetService("ReplicatedStorage")

local outFolder = workspace.Out

local values = {}

local copyOut = replicatedStorage.copyOut

local function getHighest()
	local highest = nil
	for _, value in pairs(values) do
		if not highest then
			highest = value
			continue
		end
		if value > highest then
			highest = value
		end
	end
    
    print(tostring(highest))
	local beforePos = highest.Position

	local y = beforePos.Y
	local copyPoint = Vector3.new(58.212, y+30, -68.98)
	return copyPoint
end

local function newOut()
	local newOut = copyOut:Clone()
	for i=1, 1000, 1 do
		if not values[i] then
			newOut.Name = i
			table.insert(values, newOut)
			newOut.Parent = outFolder
			newOut.Position = getHighest()
		else
		end
	end
end

newOut()

change it to this.

it now says cannot define varible < varible