Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Find an empty plot with no owner?

Asked by
CodeWon 181
3 years 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!

0
You can use a for -- do loop Omq_ItzJasmin 666 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

You can use a for — do loop

https://developer.roblox.com/en-us/articles/Loops

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
    else
        return nil -- you don't need this "else" part but just incase it makes things more clear
    end
end

Hope that helps

Ad

Answer this question