Invalid 'for' initial value (number expected, got table)?

I’m getting an error of this code:

for i = randomBlockWorth,0,-1 do
							wait(1)
							local winnersBlock = rPlayer1.leaderstats.Block.Value
							local winnersBlockR = game.Workspace:FindFirstChild(winnersBlock)
							rPlayer1.BlockValue.Value += 1
							winnersBlockR:Clone().Parent = workspace
							winnersBlockR.Position += Vector3.new(0,3,0)
						end

What’s wrong with it? I don’t understand???

1 Like

I think you are setting i=table not a value.

I think you meant to get a random value from that table, which you could do like this:

for i = randomBlockWorth[math.random(1, #randomBlockWorth)], 0, -1 do

end

Random block worth is a number though…

A math.random number i put:

local randomBlockWorth = math.random(1,10)

maybe you might’ve shadowed the variable? I believe it wouldn’t do that if that was the case

ok thanks yoours works already