Tool of game giving me a weird error

So, I v loops are loops which are used to iterate over tables, Assuming you know what tables are, Im gonna give you a short example. I’ll just show you how to color a house using this method.

local ourAmazingTable = Game.Workspace.HouseModel:GetChildren() --get children always returns a table of the object it is being performed on.

for _, v in pairs(ourAmazingTable) do -- we put our table in parenthesis
      v.BrickColor = BrickColor.Random()
end)

Now this might be confusing, but it is quite simple. i stands for index, but you can just leave it as _ and v stands for variable. As v is a variable, it can be anything. here v basically represents all of the things in the table, and our table only has parts.

Thats _, v or i, v loops in a nutshell

1 Like

I mean if it works you can learn pairs later on in the development if its to confusing for you right now.

1 Like

so i could just replace this mess with the i, v in pairs loop?

if Backpack:FindFirstChild("Stand1") or Backpack:FindFirstChild("Stand2") or Backpack:FindFirstChild("Stand3") then
				local prevStand = workspace:FindFirstChild(player.Name.." Stand")
				local prev = Backpack:FindFirstChild("Stand1") or Backpack:FindFirstChild("Stand2") or Backpack:FindFirstChild("Stand3")
				prevStand:addTo(Debris)
				prev:addTo(Debris)
				S1.Disabled = true
				S2.Disabled = true
				S3.Disabled = true

				Stand:Clone()
				Stand.Parent = Backpack
				S1.Disabled = false
			else
				Stand:Clone()
				warn("Check2")
				Stand.Parent = Backpack
				warn("Check2.0")
				S1.Disabled = false

Basically yes.

Char Max REEEEEEE (Ignore lol)

1 Like

Yeah, i, v loops are really handy

2 Likes

i have to get offline rn, tysm for the help yall, i will be back and maybe post about my progress :smiley:

1 Like

Mark a solution before you leave

1 Like