So I was trying to assign a variable to a recursive function but for some reason the variable is nil.
Heres the code:
local function right(player, counter)
if not counter then local counter = 0 end
local yes = check(player)
print(yes)
if yes == true then
counter += 1
right(player, counter)
else
print(counter) -- prints 1
return counter
end
end
local counter = 0
local rightcounter = right(player, counter)
print(rightcounter) -- prints nil
Any help would be greatly appreciated!