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
https://developer.roblox.com/en-us/articles/Loops
01 | local folder = -- ur folder |
02 | local plots = folder:GetChildren() |
03 |
04 | for _,plot in pairs (plots) do |
05 | local value = plot.Value -- specify where the value is |
06 | if value.Value = = " " or value.Value = = "" then -- how is it set to nothing? is it " " or "" |
07 | -- do your function if the plot is empty |
08 | else |
09 | return nil -- you don't need this "else" part but just incase it makes things more clear |
10 | end |
11 | end |
Hope that helps