i was trying to make a plot system but it always index randomly
also print(workspace.Plots:GetChildren()[1]) gave plot 2
and table sometime start with 8 sometime with 4 etc
local PS = script.Parent:WaitForChild("plot")
local Frame = PS:WaitForChild("SelectPlotFrame")
local left = Frame:WaitForChild("LeftArrow")
local right = Frame:WaitForChild("RightArrow")
local select1 = Frame:WaitForChild("SelectPlotButton")
local selectedplot = Frame:WaitForChild("Selectedplot")
local plots = game.Workspace.Plots
local function FindunOwnedplot ()
local avPlot = {}
for i,plot in ipairs(plots:GetChildren()) do
if plot.owner.Value == nil then
table.insert(avPlot,plot)
end
end
return avPlot
end
local plotstable = FindunOwnedplot()
print(plotstable)
local index = 1
selectedplot.Value= plotstable[1]
print(selectedplot.Value)
right.MouseButton1Up:Connect(function()
if plots:FindFirstChild("Plot"..index - 1 ) then
index -= 1
else
index = 9
end
selectedplot.Value = plotstable[index]
end)
left.MouseButton1Up:Connect(function()
if plots:FindFirstChild("Plot"..index + 1) then
index += 1
else
index = 1
end
selectedplot.Value = plotstable[index]
end)
```can someone please tell what is a problem