How to extrack numbers from a word using decimals

Hi so ive been encounterign this issue

msg = /size 2
	if msg == "/size "..tostring(NumberFromString) then
				print(NumberFromString) -- 2
			end

msg = /size 0.5
	if msg == "/size "..tostring(NumberFromString) then
				print(NumberFromString) -- nil
			end

i need some help ive been searching but havent found anything

I have no idea what you want, or what you’re trying to do, or why it isn’t working. You need to explain it fully. That code makes very little sense.

2 Likes

Is this what you’re asking for?

local msg = "/size 20" -- the original message
local content = string.split(msg, ' ') -- content in the message
local number = tonumber(content[2])

print(number) --> 20

Your post is very vague

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.