I’m making a game that requires the player to choose a plot, and I made a function to find a open plot, but I need the function to return the open plots in order depending on the plot number.
1, 2 exedra
Plot Numbers:
function:
function FindOpenPlot()
local Plots = game.Workspace.Plots:GetChildren()
for i,v in pairs(Plots) do
if v.Variables.Claimed.Value == false then
return (Plot Names in order of there Number)
end
end
function FindOpenPlot()
local Plots = game.Workspace.Plots:GetChildren()
local OpenPlots = {}
for _, v in pairs(Plots) do
if v.Variables.Claimed.Value == false then
table.insert(OpenPlots, v)
end
end
table.sort(OpenPlots, function (a, b)
return a.Variables.Claimed.Value < b.Variables.Claimed.Value
end)
return OpenPlots
end