i have multiple folders that i want to look through to check the price and print the lowest price a.k.a the attribute for every pad
local function findcheapestpad(tycoon)
local minvalue = math.huge
for _, pad in tycoon:FindFirstChild("Pads"):GetChildren() do
if pad:GetAttribute("Price") < minvalue then
minvalue = pad:GetAttribute("Price")
end
end
for _, pad in tycoon:FindFirstChild("BoughtItems"):GetChildren() do
if pad:HasTag("Pad") then
print(pad)
if pad:GetAttribute("Price") < minvalue then
minvalue = pad:GetAttribute("Price")
end
end
end
return minvalue
end
I have tried doing this but after getting to the builds folder it just returns inf
okay it works now thanks for helping i figured it out
local function findcheapestpad(tycoon)
local minvalue = math.huge
for _, pad in tycoon:FindFirstChild("Pads"):GetChildren() do
if pad:GetAttribute("Price") < minvalue then
minvalue = pad:GetAttribute("Price")
end
end
for _, build in tycoon:FindFirstChild("BoughtItems"):GetChildren() do
for _, pad in build:GetChildren() do
if pad:HasTag("Pad") then
print(pad)
if pad:GetAttribute("Price") < minvalue then
minvalue = pad:GetAttribute("Price")
end
end
end
end
return minvalue
end
i just had to make another for loop
another question though should i break the loop? i never break loops if i’m being honest