How do I make these bool values work?

So I have a shop system and I used a bunch of bool values for determining what’s owned and whatever. Anyway, I’m pretty sure the way I determined the boolean values was wrong or maybe too
vague, so I’m hoping for some insight and advice. Thanks!

The Script

--indentifying the boolvalues
local prev = index --this is the number for the item the player is trying to purchase
prev -= 1
local folder = script.Parent.boolValues --folder for my values
local prevReq = "b"..prev --each boolValue is named "b(number)" ex. b1, b2 etc.
--this is to determine the previous boolValue
prevReq = tostring(prevReq) 
prevReq = folder:WaitForChild(prevReq) --trying to find the boolean based off the name

--repeat for the current boolean value
local bool = "b"..index
bool = tostring("bool")
bool = folder:WaitForChild(bool)

if prevReq then --checking if the previous bool is true
	bool.Value = true
end

Is this in a loop, or does it only need to run once?

Only once. Well, everytime a remote event is fired I didn’t include that in the script

On the very top the “prev” value and the local bool = “b”…index

doesn’t match up. I think you have to make it

local bool = “b”…prev

for it to get the correct bool and make it false or true later…