How to detect a number value from a string

I wanna make a chat command.
Here’s it’s code:

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message == ";set dayLength" then
			
		end
	end)
end)

But there i dont know what to do. I need to get a number from message. For example: If player chatted “;set dayLength 14” , dayLength will be set to 14. So how do i do this?

u can use string.split()

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
	    --if message == ";set dayLength" then
			local msg = string.split(message, " ")
            print(msg[3])
		--end
	end)
end)

also it won’t pass the if statement so i disabled it
also see here:

1 Like

Ok i made a better script

local command = string.split(";set dayLenght", " ") -- the command

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		local splitMessage = string.split(message, " ")
		
		if splitMessage[1] == command[1] and splitMessage[2] == command[2] then
			print(splitMessage[3])
		end
	end)
end)


This should fully work now