Instance not indexing parent despite others working

i have a script that makes multiple values that determine whether a player owns a style for a radio in my game, and the beginning of the script works like this

	local ownedradios = Instance.new("Folder")
	ownedradios.Name = "OwnedRadios"
	
	local ownsgreen = Instance.new("BoolValue")
	ownsgreen.Name = "OwnsGreen"
	ownsgreen.Value = false
	
	local ownsorange = Instance.new('BoolValue')
	ownsorange.Name = 'OwnsOrange'
	ownsorange.Value = false
	
	local ownsred = Instance.new("BoolValue")
	ownsred.Name = 'OwnsRed'
	ownsred.Value = false
	
	local ownspink = Instance.new("BoolValue")
	ownspink.Name = 'OwnsPink'
	ownspink.Value = false
	
	local ownspurple = Instance.new("BoolValue")
	ownspurple.Name = 'OwnsPurple'
	ownspurple.Value = false
	
	local ownsblue = Instance.new("BoolValue")
	ownsblue.Name = 'OwnsBlue'
	ownsblue.Value = false
	
	local ownsheart = Instance.new("BoolValue")
	ownsheart.Name = 'OwnsHeart'
	ownsheart.Value = false
	
	local ownswater = Instance.new("BoolValue")
	ownswater.Name = 'OwnsWater'
	ownswater.Value = false
	
	local ownsfire = Instance.new("BoolValue")
	ownsfire.Name = 'OwnsFire'
	ownsfire.Value = false
	
	local ownsfestive = Instance.new("BoolValue")
	ownsfestive.Name = 'OwnsFestive'
	ownsfestive.Value = false
	
	local ownsgalaxy = Instance.new("BoolValue")
	ownsgalaxy.Name = 'OwnsGalaxy'
	ownsgalaxy.Value = false
	
	local ownssnow = Instance.new("BoolValue")
	ownssnow.Name = 'OwnsSnow'
	ownssnow.Value = false
	
	local ownsrainbow = Instance.new("BoolValue")
	ownsrainbow.Name = 'OwnsRainbow'
	ownsrainbow.Value = false
	
	local equipped = Instance.new("StringValue")
	equipped.Value = 'DefaultRadio'
	equipped.Name = "EquippedRadio"
	
	local data
	
	local suc, err = pcall(function()
		data = statsDS:GetAsync(plr.UserId.."-stats")
	end)
	
	if suc then
		print("data was gotten")
		if data then
			score.Value = data[1]
			equipped.Value = data[2]
			ownsgreen.Value = data[3]
			ownsorange.Value = data[4]
			ownsred.Value = data[5]
			ownsblue.Value = data[6]
			ownspurple.Value = data[7]
			ownspink.Value = data[8]
			ownsheart.Value = data[9]
			ownswater.Value = data[10]
			ownsfire.Value = data[11]
			ownsfestive.Value = data[12]
			ownsgalaxy.Value = data[13]
			ownssnow.Value = data[14]
			ownsrainbow = data[15]
		else
			score.Value = 0
			equipped.Value = 'DefaultRadio'
			ownsgreen.Value = false
			ownsorange.Value = false
			ownsred.Value = false
			ownsblue.Value = false
			ownspurple.Value = false
			ownspink.Value = false
			ownsheart.Value = false
			ownswater.Value = false
			ownsfire.Value = false
			ownsfestive.Value = false
			ownsgalaxy.Value = false
			ownssnow.Value = false
			ownsrainbow.Value = false
		end
	else
		print("an error occured")
		print(err)
	end

	ownsgreen.Parent = ownedradios
	ownsorange.Parent = ownedradios
	ownsred.Parent = ownedradios
	ownspink.Parent = ownedradios
	ownspurple.Parent = ownedradios
	ownsblue.Parent = ownedradios
	ownsheart.Parent = ownedradios
	ownswater.Parent = ownedradios
	ownsfire.Parent = ownedradios
	ownsfestive.Parent = ownedradios
	ownsgalaxy.Parent = ownedradios
	ownssnow.Parent = ownedradios
	ownsrainbow.Parent = ownedradios

however if you look at the bottom
ownsrainbow.Parent = ownedradios
it keeps giving me an error saying it could not index parent, and im confused because its the same format as all the other values and the others work, and when i remove the specific one at the bottom it works, so am i doing something wrong or is this a bug?

You are accidentally overwriting the value here:

ownsrainbow = data[15]

Picture:

I’m sure you know too, but it should be ownsrainbow.Value instead. Probably just a typo.

Also, I recommend that you use tables instead of creating 1000 different variables. It will be much easier to just put the names in a table and loop through that table. If you plan on accessing individual ones, then you can turn it into a dictionary (or just remember the indexes).

Hopefully this helped.

oh whoopsie i didnt notice that thanks