If statment meeting criteria but not working

Basically I increment a stage by one and tbls[5] is the progression and it starts at zero, but the problem is, that I need to print out the stages everytime it changes to the certain number, like for example if its 1 then it’ll say plr.Name is on stage #1, trying to do this within the script but its not working

local function UpdateStage(...)
	local args = {...}
	for i,v in pairs(args) do
		print(args[i])
	end
	if tbls[5] == args[i] then
		print(plr.Name.. " is on Stage #"..args[i])
	end
end
UpdateStage(1,2)
1 Like

You can’t use ‘i’ outside of the for loop the way you’re using it.

1 Like

Can you elaborate on that please???

1 Like

You’re using the variable “i” outside of of the loop you created using that. You can create a nil variable to take the place of it, however.

if tbls[5] == args[i] then

This part, it’s outside of the for loop. “args[i]”

1 Like

Wow I tried to make a variable and make it global insdie of the function but it still didnt seem to work but after putting it inside of the loop it works perfectly fine now thanks for the help

I see what you mean I fixed it

1 Like