How to get the number from a string

  1. What do you want to achieve?
    I want to find out how I would get a number from a string

  2. What solutions have you tried so far?
    I looked around on the DevForum but all I can see is how you would change a number with string.gsub

local Word = 'Hello15'

I want to be able to print the 15 with a shorter script than below and automate the process with a loop
My current script:

local Word = 'Hello15'

Word = string.sub(Word,6,#Word)

print(Word) --prints 15

use gsub

local Word = 'Hello15'
Word = string.gsub(Word, "%D", "")

print(Word)
1 Like

Try reading other forums before you post,

Thanks, I did look around but I didn’t find that topic