How to automatically edit text?

If you don’t understand what i mean, i don’t blame you because i don’t know how to ask this (if i did i would probably somehow find on google), anyways, what i mean is i have a text that says "Score: " and i want it to increment by 1 when a player does something so it says “Score: 1” and “Score: 2” and so on… I got everything set up but i just can’t figure that out, i searched google for string formatting, string editing and stuff like that but i couldn’t find anything.

If you need any code or anything just ask and i will post.

Any help is appreciated.

(and also i’m new on the forum so i’m sorry if i did something wrong)

local myText=display.newText( " ", display.contentWidth\*.5, display.contentHeight\*.5, native.systemFont, 20 ) myText.baseText="Score: " myText.counter=0 myText.updateText=function(increment) myText.counter=myText.counter+increment myText.text=myText.baseText..tostring(myText.counter) end -- Format the initial score myText.updateText(0) -- Then sometime later, -- increment the score by 1 myText.updateText(1)
local myText=display.newText( " ", display.contentWidth\*.5, display.contentHeight\*.5, native.systemFont, 20 ) myText.baseText="Score: " myText.counter=0 myText.updateText=function(increment) myText.counter=myText.counter+increment myText.text=myText.baseText..tostring(myText.counter) end -- Format the initial score myText.updateText(0) -- Then sometime later, -- increment the score by 1 myText.updateText(1)