Plot system not working for some reason

Edit: (Sorry for the code below in red, tried to fix it but to no avail.)
I had a topic on this on another post, but not on a script issue because I thought I should post it here.

for i, v in pairs(plots:GetDescendants()) do 
   	Plot = not v:FindFirstChild("StringValue") -- problem is here, i'm trying to get every plot that doesn't have a string value, but when I print it, it just prints true.```


My goal is trying to get all available plots that don't have a string value.

```lua

local repstorage = game:GetService("ReplicatedStorage")
local rm = repstorage:WaitForChild("RemoteEvent")
local plots = workspace.plots.Model


rm.OnServerEvent:Connect(function(player, char)
   local humroot = char:FindFirstChild("HumanoidRootPart")
   local Plot = nil
    for i, v in pairs(plots:GetDescendants()) do 
   	Plot = not v:FindFirstChild("StringValue")
   		print(Plot)
   	end
   ----local tpPort = Plot
   ---if tpPort == plots.plot3 then
   	---humroot.Position = Vector3.new(33.13, 1.5, 33.48)
   	
   		---if tpPort == plots.plot4 then
   		---humroot.Position = Vector3.new(33.13, 1.5, -120.04)
   		
   					---if tpPort == plots.plot2 then
   			---humroot.Position = Vector3.new(51.5, 1.5, 33.48)
   			
   						---if tpPort == plots.plot1 then
   	---humroot.Position = Vector3.new(51.5, 1.5, -120.04)
   ---end
   	
   ---if Plot then
   	---- check if player has gamepass.
   	
   	--- else click assign to assign plot
   		------local obj = Instance.new("StringValue")
   	------obj.Parent = Plot
   end
   end
   	end
   end
   end)```
1 Like

Instead u can do this

for i, v in pairs(plots:GetChildren()) do 
   	if not v:FindFirstChildWhichIsA("StringValue") then
--whatever you will write here
--and u will just keep using v instead of Plot
--for example
print(v.Name.." Is A free plot")
--if u want to ask any questions i would be happy to answer 
end
end

Note: I Changed GetDescendants to GetChildren and FindFirstChild() To FindFirstChildWhichIsA()

Works perfectly, thanks a bunch!

1 Like

No Problem Happy To Help :smile: