How to extract the value of the variable from the function?

How to extract the value of the variable from the function? e.g. I want to get value from “levelUp” and input it in the new variable outside the function.

local function push()

    tapCount = tapCount + 1

    tapText.text = tapCount

    if tapCount == 5 then

      levelUp = levelUp + 1

      levelValue.text = levelUp

      tapCount = 0

    end

This is a question about scope. You can find a good tutorial from Corona on this topic at: https://docs.coronalabs.com/tutorial/basics/scope/index.html

Simple… simply return it at the end of the function

local function push() tapCount = tapCount + 1 tapText.text = tapCount if tapCount == 5 then levelUp = levelUp + 1 levelValue.text = levelUp tapCount = 0 end return levelUp \<-- this is what you are missing end

This is a question about scope. You can find a good tutorial from Corona on this topic at: https://docs.coronalabs.com/tutorial/basics/scope/index.html

Simple… simply return it at the end of the function

local function push() tapCount = tapCount + 1 tapText.text = tapCount if tapCount == 5 then levelUp = levelUp + 1 levelValue.text = levelUp tapCount = 0 end return levelUp \<-- this is what you are missing end