Log in to vote

Find an empty plot with no owner?

Asked by
CodeWon 121
1 month ago

I'm trying to make plots and and I have a plots folder, a plot model in the folder, and a string value named owner in the plot model. I'm trying to make a function that finds a plot where the owner value is equal to nothing, and if it is, it will set the owner value to the players name. If the owner value already has the value of a players name, it will find another plot that is empty. How can I do this?

I hope I explained that well enough, thank you!

You can use a for -- do loop Omq_ItzJasmin 621 — 1mo

1 answer

Log in to vote
Answered by 1 month ago
Edited 1 month ago

You can use a for — do loop

local folder = -- ur folder
local plots = folder:GetChildren()

for _,plot in pairs(plots) do
    local value = plot.Value -- specify where the value is
    if value.Value == " " or value.Value == "" then -- how is it set to nothing? is it " " or ""
        -- do your function if the plot is empty
        return nil -- you don't need this "else" part but just incase it makes things more clear

Hope that helps


Answer this question