Is there a better way to replace elseif?

Hello, I’m create a reporting system, but I’m unsure on how to create a efficient method because you can’t add values to arrays. Any help is appreciated. Thank you.

local reports = {}

if reports[targetPlayer] == nil then				
	reports[targetPlayer] = 1			
elseif reports[targetPlayer] == 1 then				
	reports[targetPlayer] = 2			
elseif reports[targetPlayer] == 2 then				
	reports[targetPlayer] = 3
end

Although this seems short I actually cut most of the script because it would be too long.

You can use another method like:

if reports[targetPlayer] == nil then
reports[targetPlayer] = 1
elseif reports[targetPlayer] > 1 then
–script here
elseif reports[targetPlayer] > 2 then
–script here
end

I don’t really think there is another to replace elseif.

1 Like

You can add values to arrays

local reports= {}

if not reports[targetPlayer] then
reports[targetPlayer] = 0
end
reports[targetPlayer] = repo[targetPlayer]  +1
3 Likes