Hello everybody! I am currently making a command script. However for some reason the chat cannot detect a number in the message I sent.
game.Players.Rescripted_Developer.Chatted:connect(function(msg)
if msg == "/FPS"..tonumber(msg) then
script.FPS.Value = msg
end
if msg == "/Quality"..tonumber(msg) then
script.Quality.Value = msg
end
end)
local NumberFromString = string.match("The Cloud Kingdom has 25 power gems", "%d+")
-- prints "25" so you write this:
local NumberFromString = string.match(msg , "%d+")
local msg = "/FPS17"
local command, value = string.match(msg, "/(%a+)%s*(%d+)")
print(command)
print(value)
if (command == "FPS" and value ~= nil) then
script.FPS.Value = value
elseif (command == "Quality" and value ~= nil) then
script.Quality.Value = value
end
game.Players.Rescripted_Developer.Chatted:connect(function(msg)
local NumberFromString = string.match(msg , "%d+")
if msg == "/FPS"..NumberFromString then
script.FPS.Value = NumberFromString
end
if msg == "/Quality"..tonumber(NumberFromString) then
script.Quality.Value = NumberFromString
end
end)
i think this is what you are trying to achieve
(edit)
or this sorry didnt see u were concatinating a tonumber
game.Players.Rescripted_Developer.Chatted:connect(function(msg)
local NumberFromString = string.match(msg , "%d+")
if msg == "/FPS"..tostring(NumberFromString) then
script.FPS.Value = NumberFromString
end
if msg == "/Quality"..tostring(NumberFromString) then
script.Quality.Value = NumberFromString
end
end)