How to automatically edit text?

You probably don’t understand what I mean but I don’t blame you because I don’t know how to ask this (if I did I would probably find it on Google) but anyways, here is what I meant: I have some text that says "Score: " and I want it to increment by 1 everytime a player does something so it goes like this “Score: 1”, “Score: 2” and so on…

I’ve got everything set up I just can’t figure that out, any help is appreciated.

Well, this may be a bit advanced for you, but this is how I handle score keeping (sometimes)

-- -- This is not great, but it it totally functional. My method really has more parts, but this -- is a simplification which you can expand upon later. -- local scoreLabel = display.newText( "Score: 0", display.contentCenterX, 100 ) scoreLabel.value = 0 function scoreLabel.onScore( self, event ) if( event.value ) then self.value = self.value + event.value score.text = "Score: " .. tostring( self.value ) end end Runtime:addEventListener( "onScore", scoreLabel ) function scoreLabel.finalize( self ) Runtime:removeEventListener("onScore",self) end scoreLabel:addEventListener("finalize")

Now, at a later date I can do this ANYWHERE and the score will ‘auto-update’

local circle = display.newCircle( 100, 100, 100 ) function circle.touch( self, event ) if( event.phase == "ended" ) then Runtime:dispatchEvent( { name = "onScore", value = math.random(1,5) } ) end end circle:addEventListener("touch")

Tapping the circle adds to our score and the label auto-updates.

CODE MAY CONTAIN TYPOS

Well, this may be a bit advanced for you, but this is how I handle score keeping (sometimes)

-- -- This is not great, but it it totally functional. My method really has more parts, but this -- is a simplification which you can expand upon later. -- local scoreLabel = display.newText( "Score: 0", display.contentCenterX, 100 ) scoreLabel.value = 0 function scoreLabel.onScore( self, event ) if( event.value ) then self.value = self.value + event.value score.text = "Score: " .. tostring( self.value ) end end Runtime:addEventListener( "onScore", scoreLabel ) function scoreLabel.finalize( self ) Runtime:removeEventListener("onScore",self) end scoreLabel:addEventListener("finalize")

Now, at a later date I can do this ANYWHERE and the score will ‘auto-update’

local circle = display.newCircle( 100, 100, 100 ) function circle.touch( self, event ) if( event.phase == "ended" ) then Runtime:dispatchEvent( { name = "onScore", value = math.random(1,5) } ) end end circle:addEventListener("touch")

Tapping the circle adds to our score and the label auto-updates.

CODE MAY CONTAIN TYPOS